Click here to Skip to main content
15,034,598 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have a class:
C++
class taphop
{
	public:
	        taphop();
                ~taphop();   
		taphop(const list&);
		taphop& operator=(const taphop&);
		taphop operator+(const int&);
                taphop operator+(const taphop&);
}

in main, i can't using multiple parameters:
C++
main()
{
     taphop lmc=lmc+2+5+3+2; // Error;
     lmc=lmc+3+5+2; // Error;
     int a=a+1+2+4+5;   // Not error;
     return 0;
}

Can everyone help me?? Plz, tks.
Posted

You forgot to terminate your class definition. It should have a semi-colon after the closing brace, thus:
C++
class taphop
{
public:
        taphop();
        ~taphop();   
	taphop(const list&);
	taphop& operator=(const taphop&);
	taphop operator+(const int&);
        taphop operator+(const taphop&);
};
   
very easy:

taphop lmc(2+5+3+2); // write a clear constructor;


Further Tips:

- better style: class names begin with big letter (I like camle-case: TapHop or CTApHop)
- only on statement per line
- in thise case: better use functions instead of operators => add(int n) leads to better debugging
   
Comments
Member 11230457 13-Nov-14 7:04am
   
It 's not different from lmc(12); 12 is a integer, not a taphop type, ide will use defaut copy constructor. pLZ help,

p/s:i'm from vietnam, so that ...

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900