[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.c++

Noob: What is the error in this code?

noemailplease0001

10/7/2008 6:11:00 PM


#ifndef POSITION_H_
#define POSITION_H_

class Position
{
public:
Position(std::string name, std::string name):
m_name( name), m_description(description){}
std::string toString();
private:
std::string m_name;
std::string m_description;

};

#endif /* POSITION_H_ */

I get an error 'error: expected `;' before "m_description"' I don't
understand that.

Thanks for ur time

-N.E
2 Answers

mlt

10/7/2008 6:22:00 PM

0


<noemailplease0001@gmail.com> wrote in message
news:92e08422-9186-4edd-ac49-5287fbb6949d@25g2000prz.googlegroups.com...
>
> #ifndef POSITION_H_
> #define POSITION_H_
>
> class Position
> {
> public:
> Position(std::string name, std::string name):
> m_name( name), m_description(description){}
> std::string toString();
> private:
> std::string m_name;
> std::string m_description;
>
> };
>
> #endif /* POSITION_H_ */
>
> I get an error 'error: expected `;' before "m_description"' I don't
> understand that.
>
> Thanks for ur time
>
> -N.E

Should the second argument in the constructor not be 'description':

Position(std::string name, std::string description):

Daniel T.

10/7/2008 11:21:00 PM

0

In article
<92e08422-9186-4edd-ac49-5287fbb6949d@25g2000prz.googlegroups.com>,
noemailplease0001@gmail.com wrote:

> #ifndef POSITION_H_
> #define POSITION_H_
>
> class Position
> {
> public:
> Position(std::string name, std::string name):
> m_name( name), m_description(description){}
> std::string toString();
> private:
> std::string m_name;
> std::string m_description;
>
> };
>
> #endif /* POSITION_H_ */
>
> I get an error 'error: expected `;' before "m_description"' I don't
> understand that.
>
> Thanks for ur time
>
> -N.E

"ComeauTest.c", line 7: error: name followed by "::" must be a class or
namespace
name... Wild guess: Did you #include the right header?
Position(std::string name, std::string name):
^

"ComeauTest.c", line 7: error: expected a ")"
Position(std::string name, std::string name):
^

"ComeauTest.c", line 7: error: name followed by "::" must be a class or
namespace
name... Wild guess: Did you #include the right header?
Position(std::string name, std::string name):
^

"ComeauTest.c", line 7: error: expected a ";" (perhaps on the previous
statement)
Position(std::string name, std::string name):
^

"ComeauTest.c", line 11: error: name followed by "::" must be a class or
namespace
name... Wild guess: Did you #include the right header?
std::string m_name;
^

"ComeauTest.c", line 12: error: name followed by "::" must be a class or
namespace
name... Wild guess: Did you #include the right header?
std::string m_description;
^

6 errors detected in the compilation of "ComeauTest.c".