类,字符串,在VS.NET中学习 [英] classes, strings, learning in VS.NET

查看:48
本文介绍了类,字符串,在VS.NET中学习的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我正在用Bjarne Stroustrup的书学习c ++,我只需在他的书中输入

到Visual Studio .NET中。对于

来说,这是一个好的编译器吗?我开始怀疑了......它需要是没有.NET框架的ANSI C ++




无论如何,什么''错了:

=====================>

班级员工{

短片;

公开:

员工();

};


void main(){

员工e =员工();

}

< ========= ========

我把它放在1个文件中并构建,VS抱怨:


错误LNK2001:未解析的外部符号public :__thiscall

员工::员工(无效)" (?? 0Employee @@ $$ FQAE @ XZ)

致命错误LNK1120:1个未解决的外部


TIA

解决方案

FQAE @ XZ)

致命错误LNK1120:1个未解决的外部因素


TIA

An Ony写道:


这真的是你的名字吗?你的电子邮件地址无效......

我只是用Bjarne Stroustrup的书来学习c ++,我只是在他的书中输入了Visual Studio中的内容。净。这对
来说是否是一个好的编译器?我开始怀疑了......它需要是ANSI C ++


这是一个很好的编译器,至少是2003版本。

无论如何,这有什么问题:
=====================>
班级员工{
短部门;
公开:
员工();


这里你声明你将为你的员工提供一个构造函数

类。


后来,链接器告诉你它无法找到一个。所以要么删除

这一行,编译器会自动为你生成一个构造函数

或保留你的承诺并实现它:


员工::员工(){

//做任何有用的事情

}

};

无效main(){


int main(){


不允许使用main。

员工e =员工();


看起来很奇怪。为什么不简单:


员工e;

}




希望这会有所帮助,


Christoph


> >我正在学习使用Bjarne Stroustrup的书来学习c ++,而我只需要
类型

他的书中的Visual Studio是什么。净。这对
来说是否是一个好的编译器?我开始怀疑了......它需要是ANSI


C ++
这是一个很好的编译器,至少是2003版本。

无论如何,这有什么问题:
=====================>
班级员工{<短片;
公开:
员工();



在此声明您将为Employee
类提供构造函数。

稍​​后,链接器会通知您它无法找到。所以要么删除这一行,编译器会自动为你生成一个构造函数
或者保守你的承诺并实现它:

员工::员工(){
/ /做任何有用的事情
}

};

void main(){



int main(){

主不允许使用void。

员工e =员工();


看起来很奇怪。为什么不简单:

员工e;

}



啊谢谢,我''我现在去试试吧。我习惯用Java编程,这就是我认为它是逻辑的。那本书说,没有声明没有

初始化,所以不是雇员e;有点不对?


Hi,
I''m just learning c++ with the book from Bjarne Stroustrup and I just type
what is in his book into Visual Studio .NET. Is that a good compiler for
that or not? I''m beginning to have my doubts... and it needs to be ANSI C++
without the .NET framework.

anyway, what''s wrong with this:
=====================>
class Employee {
short dept;
public:
Employee();
};

void main(){
Employee e = Employee();
}
<=================
I just put this in 1 file and build, VS complains:

error LNK2001: unresolved external symbol "public: __thiscall
Employee::Employee(void)" (??0Employee@@$$FQAE@XZ)
fatal error LNK1120: 1 unresolved externals

TIA

解决方案

FQAE@XZ)
fatal error LNK1120: 1 unresolved externals

TIA


An Ony wrote:

Is that really your name? And your email address is invalid...

I''m just learning c++ with the book from Bjarne Stroustrup and I just type
what is in his book into Visual Studio .NET. Is that a good compiler for
that or not? I''m beginning to have my doubts... and it needs to be ANSI C++
It is a good Compiler, at least the 2003 version.
anyway, what''s wrong with this:
=====================>
class Employee {
short dept;
public:
Employee();
Here you declare that you will provide a constructor for your Employee
class.

Later, the linker informs you that it couldnt find one. So either remove
this line and the compiler generates a Constructor automatically for you
or keep your promise and implement it:

Employee::Employee() {
// Do whatever is useful here
}
};

void main(){
int main() {

void is not allowed for main.
Employee e = Employee();
Looks weird. Why not simply:

Employee e;
}



Hope this helps,

Christoph


> > I''m just learning c++ with the book from Bjarne Stroustrup and I just
type

what is in his book into Visual Studio .NET. Is that a good compiler for
that or not? I''m beginning to have my doubts... and it needs to be ANSI

C++
It is a good Compiler, at least the 2003 version.

anyway, what''s wrong with this:
=====================>
class Employee {
short dept;
public:
Employee();



Here you declare that you will provide a constructor for your Employee
class.

Later, the linker informs you that it couldnt find one. So either remove
this line and the compiler generates a Constructor automatically for you
or keep your promise and implement it:

Employee::Employee() {
// Do whatever is useful here
}

};

void main(){



int main() {

void is not allowed for main.

Employee e = Employee();



Looks weird. Why not simply:

Employee e;

}


ah thanks, I''ll go try it now. I''m used to program in Java so that''s how I
thought it was logic. And that book said, "don''t declare without
initialization", so isn''t "Employee e;" kinda wrong?


这篇关于类,字符串,在VS.NET中学习的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆