GIDForums  

Go Back   GIDForums > Computer Programming Forums > C++ Forum
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

 
 
Thread Tools Search this Thread Rate Thread
  #1  
Old 13-Apr-2005, 12:02
kai85 kai85 is offline
...is NOT a boy!
 
Join Date: Jan 2005
Posts: 58
kai85 is on a distinguished road

defining a struct inside a class :(


1-Ive defined a class and inside that class ive defined a struct to create a new type, there are a few member functions in the class . these functions return a number of the structs type(sorry if the phrases I use aren’t correct,.....) anyway what I was wondering is this, what is the function definitions format ?
Isn’t it supposed to be like this:
CPP / C++ / C Code:
Stuct-type [b]classname::[/b]memberfunction-name(parameters and their ypes){
//...
}
But I get this error:
"error C2556: 'struct complex __thiscall complexc::make_complex(double,double)' : overloaded function differs only by return type from 'struct complexc::complex __thiscall complexc::make_complex(double,doub"

(if I delete the bold part then I don’t get the above error but I get a whole bunch of new ones.......)


I have no idea why I get this error, I haven’t over-loaded any function(assuming I’ve understood exactly what function-overloading is )
Off-course I know that if I over-load a function then the function’s parmeters have to differ with one another, ......but the problem is I haven’t overloaded any functions.
2- if one of these member-functions was supposed to call another member-function then how does it do that?(I want the format)

Please reply as soon as possible.
  #2  
Old 13-Apr-2005, 13:26
QED's Avatar
QED QED is offline
Member
 
Join Date: Feb 2005
Location: Hudson Valley, NY
Posts: 231
QED is a jewel in the roughQED is a jewel in the roughQED is a jewel in the rough
Without seeing actual code and all error messages, I can not be 100% certain.

However, probably you have left out the scope from the return type. Since the struct is declared in the class, outside the class the symbol may not mean anything (or if it does, probably it means something else). For example,
CPP / C++ / C Code:
class Class {
public:
  // constructors and other members might go here

  struct InnerStruct {
  };

  InnerStruct method(int x);
};

Class::InnerStruct Class::method(int x)
{
  // definition goes here
}


Not sure how to answer your second question without more details of what you have tried so far and where it seems to go wrong.

Matthew
  #3  
Old 14-Apr-2005, 02:56
kai85 kai85 is offline
...is NOT a boy!
 
Join Date: Jan 2005
Posts: 58
kai85 is on a distinguished road
Quote:
Originally Posted by QED
Without seeing actual code and all error messages, I can not be 100% certain.

However, probably you have left out the scope from the return type. Since the struct is declared in the class, outside the class the symbol may not mean anything (or if it does, probably it means something else). For example,
CPP / C++ / C Code:
class Class {
public:
  // constructors and other members might go here

  struct InnerStruct {
  };

  InnerStruct method(int x);
};

Class::InnerStruct Class::method(int x)
{
  // definition goes here
}


Not sure how to answer your second question without more details of what you have tried so far and where it seems to go wrong.

Matthew



thanx, it seems thats exactly what i haven't done.(my so-called tutor never said anything !!!)
lemme go work on that and see if i get any more errors.
kai85.
 
 

Recent GIDBlogObservations of Iraq by crystalattice

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Rate This Thread
Rate This Thread:

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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
2D arrays:dynamic allocation and freeing bravetanveer C Programming Language 48 27-Nov-2007 15:55
Urgent ! Pls Help Me ! mycashmoney C Programming Language 4 01-Jul-2006 22:49
[Tutorial] GUI programming with FLTK dsmith FLTK Forum 10 03-Oct-2005 15:41
Error C2146: syntax error : missing ',' before identifier 'C4' mattchew008 C++ Forum 2 19-Dec-2004 06:06

Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The

All times are GMT -6. The time now is 13:36.


vBulletin, Copyright © 2000 - 2008, Jelsoft Enterprises Ltd.