Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > class definitions

Reply
Thread Tools

class definitions

 
 
aliboyaci@gmail.com
Guest
Posts: n/a
 
      07-18-2006
class a {
int x(b * _b);
};

class b {
int y(a * _a);
};

i want to make a definiton like that but i have errors. how can i solve
this ?

error : 4
expected `;' before '(' token

 
Reply With Quote
 
 
 
 
Victor Bazarov
Guest
Posts: n/a
 
      07-18-2006
http://www.velocityreviews.com/forums/(E-Mail Removed) wrote:
> class a {
> int x(b * _b);
> };
>
> class b {
> int y(a * _a);
> };
>
> i want to make a definiton like that but i have errors. how can i
> solve this ?
>
> error : 4
> expected `;' before '(' token


Look up "forward declaration" in the FAQ. And next time read the
FFAQ before posting, please.

V
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask


 
Reply With Quote
 
 
 
 
osmium
Guest
Posts: n/a
 
      07-18-2006
<(E-Mail Removed)> wrote:

> class a {
> int x(b * _b);


What do you *want* to have happen here? Is '*' meant to be the multiply
operator? b is (will be) a class, and classes have no value - only objects
have values. And what is "_b" supposed to represent?

> };
>
> class b {
> int y(a * _a);
> };
>
> i want to make a definiton like that but i have errors. how can i solve
> this ?
>
> error : 4
> expected `;' before '(' token
>



 
Reply With Quote
 
Victor Bazarov
Guest
Posts: n/a
 
      07-18-2006
osmium wrote:
> <(E-Mail Removed)> wrote:
>
>> class a {
>> int x(b * _b);

>
> What do you *want* to have happen here? Is '*' meant to be the
> multiply operator? b is (will be) a class, and classes have no value
> - only objects have values. And what is "_b" supposed to represent?


Uh... It's a declaration of a funciton 'x' that takes a pointer to 'b'
and returns an 'int'...

> [...]


V
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask


 
Reply With Quote
 
osmium
Guest
Posts: n/a
 
      07-18-2006
"osmium" writes:

> <(E-Mail Removed)> wrote:
>
>> class a {
>> int x(b * _b);

>
> What do you *want* to have happen here? Is '*' meant to be the multiply
> operator? b is (will be) a class, and classes have no value - only
> objects have values. And what is "_b" supposed to represent?


OK, I seen now what you wanted, and have already received an answer to your
question, I saw the leading underscore as a kind of "magic incantation" and
got sidetracked. Sorry about that.


 
Reply With Quote
 
ali
Guest
Posts: n/a
 
      07-18-2006
thanx alot Victor

next time i will first read to faq
as Victor said

forward declaration :

------a.h-------
class b;
class a {
int x(b * _b);
};
------a.h-------

------b.h-------
class a;
class b {
int x(a * _a);
};
------b.h-------

 
Reply With Quote
 
Mark P
Guest
Posts: n/a
 
      07-19-2006
ali wrote:
> thanx alot Victor
>
> next time i will first read to faq
> as Victor said
>
> forward declaration :
>
> ------a.h-------
> class b;
> class a {
> int x(b * _b);
> };
> ------a.h-------
>
> ------b.h-------
> class a;
> class b {
> int x(a * _a);
> };
> ------b.h-------
>


Just some suggestions...

I think your function declarations would be more readable if the * were
put immediately adjacent to the typename, e.g.:

int x(b* _b);

Additionally, I find that type names and variable names that differ only
be a punctuation symbol are confusing to look at.

And finally, user-defined names should not begin with an underscore as
these are reserved for the implementation.
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
moving class indepdent methods out of class definitions Rainer Weikusat Perl Misc 1 03-08-2013 06:41 PM
Nested Class, Member Class, Inner Class, Local Class, Anonymous Class E11 Java 1 10-12-2005 03:34 PM
Re: Splitting up the definitions of a class into different files (splitting public from private)? John Dibling C++ 0 07-19-2003 04:41 PM
Re: Splitting up the definitions of a class into different files (splitting public from private)? Mark C++ 0 07-19-2003 04:24 PM
Re: Splitting up the definitions of a class into different files (splitting public from private)? John Ericson C++ 0 07-19-2003 04:03 PM



Advertisments