learning classes

  • Thread starter Thread starter An Ony
  • Start date Start date
A

An Ony

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. Now that I think about it, is "visual c++"
something else than the ANSI c++?

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
 
An said:
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. Now that I think
about it, is "visual c++" something else than the ANSI c++?

VC++.NET 2003 (aka VC7.1) is a highly (but not completely) standard
conformant C++ compiler. Make sure that you're creating "Win32 Console
Applications" as your project type in the Visual Studio IDE.
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

You've declared but not defined Employee::Employee(), so the error is
expected and correct.

Try this:

class Employee
{
short dept;
public:
Employee();
};

Employee::Employee()
{
dept = 0;
}

void main()
{
Employee e = Employee();
}

-cd
 
Back
Top