#include <iostream>

using namespace std;

class A
{
private:

	int a;

};

A::A()
{
	a = 10;
}

int main()
{ 
	A obj1;

	cin.ignore();
	cin.get();

}

It is giving me the error

Error 1 error C2600: 'A::A' : cannot define a compiler-generated special member function (must be declared in the class first) c:\documents and settings\levi\desktop\stfu\stfu\main.cpp 14

Am I just completely forgetting to do something? The error message makes it sound like A is a function, when Im just trying to declare a variable using a default constructor. Help please!

Oh wow, I didnt declare the constructor. Never mind...

If you provide a definition for the constructor for that class, you need
to define the constructor. That statement is what the error is saying.
For example :

Correct way

class Test{
  int i;
public:
  Test();
};
Test::Test(){ i = 10; }

Incorrect or wrong

class Test{
 int i;
};
Test::Test(){ i = 10; }
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.