6 Replies - 3095 Views - Last Post: 30 October 2009 - 11:20 AM Rate Topic: -----

#1 fenx591  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 13
  • Joined: 16-September 08

Compiler Error C2533

Post icon  Posted 29 October 2009 - 03:18 PM

hello everyone

I keep getting this error Compiler Error C2533 Error Message
'identifier' : constructors not allowed a return type. i have tried everything i can to fix it but it doesn't work . any help is appreciated thank you. The code is the header file, and the .cpp for the class implementation

#include<iostream>
#include<string>
using namespace std;


class Apartment
{
	public:
		Apartment();
		Apartment(int b, int a, int t, int v,string n,double d);
		
		
		int get_bu_num (int b);
		int get_app_num (int a);
		int get_type (int t);
		int get_view (int v);
		string get_name (string n);
		double get_amount_due (double d);
		void set_name (string n);				//MUTATOR
		void set_amount_due(double d);			//MUTATOR
		void pay_rent(double amount);
		double calculate_rent() const; 
		void display_info() const;
		void new_month();
	
	private:
		int bu_num;
		int app_num;
		int type;
		int view;
		string name;
		double due;
}




#include<iostream>
#include<string>
using namespace std;
#include"Apartment.h"

Apartment::Apartment()
{   bu_num=0;
	app_num=0;
	type=0;
	view=0;
	name="------";
	due=0;
}

int Apartment::get_bu_num(int b)
{
	return bu_num;
}

int Apartment::get_app_num(int a)
{
	return app_num;
}

int Apartment::get_type(int t)
{
	return type;
}

int Apartment::get_view(int v)
{
	return view;
}

string Apartment::get_name(string n)
{
	return name;
}







Is This A Good Question/Topic? 0
  • +

Replies To: Compiler Error C2533

#2 JackOfAllTrades  Icon User is offline

  • Saucy!
  • member icon

Reputation: 5957
  • View blog
  • Posts: 23,226
  • Joined: 23-August 08

Re: Compiler Error C2533

Posted 29 October 2009 - 03:35 PM

Add a semi-colon after the class declaration in your header file
class Apartment
{
    /// code, code, code...
}; // <- here

Was This Post Helpful? 0
  • +
  • -

#3 fenx591  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 13
  • Joined: 16-September 08

Re: Compiler Error C2533

Posted 29 October 2009 - 03:45 PM

View PostJackOfAllTrades, on 29 Oct, 2009 - 02:35 PM, said:

Add a semi-colon after the class declaration in your header file
class Apartment
{
    /// code, code, code...
}; // <- here


yea i found that , thnx but now i get these errors...1>Linking...
1>MSVCRTD.lib(crtexe.obj) : error LNK2019: unresolved external symbol _main referenced in function ___tmainCRTStartup
1>F:\foundations of computer science\assigment\visual studio\homework6\Debug\homework6.exe : fatal error LNK1120: 1 unresolved externals

:crazy:
Was This Post Helpful? 0
  • +
  • -

#4 KYA  Icon User is offline

  • g++ jameson.cpp -o beverage
  • member icon

Reputation: 3089
  • View blog
  • Posts: 19,137
  • Joined: 14-September 07

Re: Compiler Error C2533

Posted 29 October 2009 - 03:51 PM

What's your main look like?
Was This Post Helpful? 0
  • +
  • -

#5 fenx591  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 13
  • Joined: 16-September 08

Re: Compiler Error C2533

Posted 29 October 2009 - 04:01 PM

View PostKYA, on 29 Oct, 2009 - 02:51 PM, said:

What's your main look like?


i dont have one yet , but ti shouldnt matter no?.. because its just the class definition and implementation
Was This Post Helpful? 0
  • +
  • -

#6 JackOfAllTrades  Icon User is offline

  • Saucy!
  • member icon

Reputation: 5957
  • View blog
  • Posts: 23,226
  • Joined: 23-August 08

Re: Compiler Error C2533

Posted 29 October 2009 - 04:56 PM

If you're compiling to an executable, yeah...you need a main.
Was This Post Helpful? 0
  • +
  • -

#7 fenx591  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 13
  • Joined: 16-September 08

Re: Compiler Error C2533

Posted 30 October 2009 - 11:20 AM

View PostJackOfAllTrades, on 29 Oct, 2009 - 03:56 PM, said:

If you're compiling to an executable, yeah...you need a main.



#include<iostream>
#include<string>
#include"Apartment.h"
using namespace std;

int main()
{
	Apartment a1,a2;
	a1.pay_rent(130);
	//Apartment a[100];

}





#include<iostream>
#include<string>
#include"Apartment.h"
using namespace std;


Apartment::Apartment()
{   bu_num=0;
	app_num=0;
	type=0;
	view=0;
	name="------";
	amount_due=0;
}

int Apartment::get_bu_num(int b)
{
	return bu_num;
}

int Apartment::get_app_num(int a)
{
	return app_num;
}

int Apartment::get_type(int t)
{
	return type;
}

int Apartment::get_view(int v)
{
	return view;
}

string Apartment::get_name(string n)
{
	return name;
}

double Apartment::get_amount_due(double d)
{
	return amount_due;
}

void Apartment::set_name(string n)
{
	name = n;
}
void Apartment::set_amount_due(double d)
{
	amount_due -= d;

}

void Apartment::pay_rent(double amount)
{
	amount_due -= amount;
}

double Apartment::calculate_rent()
{
	if (type==1)
	{ total_rent = 850;
	}

	if (type==2)
	{total_rent=1050;
	}

	if (type==3)
	{total_rent=1250;
	}
	if(view==true)
	{total_rent+=75;
	}
	if(app_num>=300)
	{total_rent+=50;
	}
return total_rent;
}



#include<iostream>
#include<string>
using namespace std;


class Apartment
{
	public:
		Apartment();
		Apartment(int b, int a, int t, int v,string n,double d);
		
		
		int get_bu_num (int b);
		int get_app_num (int a);
		int get_type (int t);
		int get_view (int v);
		string get_name (string n);
		double get_amount_due (double d);
		void set_name (string n);				//MUTATOR
		void set_amount_due(double d);			//MUTATOR
		void pay_rent(double amount);
		double calculate_rent(); 
		void display_info();
		void new_month();
		
	
	private:
		int bu_num;
		int app_num;
		int type;
		int view;
		string name;
		double amount_due;
		double total_rent;
};




now its giving me this error fatal error C1083 cannot open include file: 'Apartment.h': No such file or directory , dunno why because it is in there
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1