Talk About Network

Google





Programming > C - C++ Learning > Re: Help with C...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 2 of 9 Topic 4210 of 4400
Post > Topic >>

Re: Help with Compile Error :)

by Ben Cottrell <bench@[EMAIL PROTECTED] > Jul 19, 2008 at 08:26 PM

Kush wrote:
> Hello,
> 
> I am attempting to create a small program to teach a colleague how to
> program using C++ but I seem to be having my own difficulties with a
> compile error.  It has been quite some time since I last wrote code in
> general, led alone in C++.
> 
> I was wondering if someone wouldn't mind pointing out the source of my
> problem.  :)
> 
> The compile error I am getting is below and occurs in the
> RunProgram :: Run method definition
> 
> error C2228: left of '.GetRunnersNameByIndex' must have class/struct/
> union type
> error C2228: left of '.GetRaceTimePerRunnerByIndex' must have class/
> struct/union type
> error C2228: left of '.GetEnvironmentalCoefficient' must have class/
> struct/union type


> class RunProgram
> {
> 	private:
> 		RaceCoordinator raceCoordinator();

//Snipped for brevity

> void RunProgram :: Run(void)
> {
> 	cout << "The race results are:" << endl;
> 	cout << "Name \t\t Time" << endl;
> 
> 	for (int i = 0; i <= 9; ++i)
> 	{
> 		cout << this->raceCoordinator.GetRunnersNameByIndex(i) << "\t\t" <<
> this->raceCoordinator.GetRaceTimePerRunnerByIndex(i) / this-
> 
>>raceEnvironmentalFactors.GetEnvironmentalCoefficient() << endl;


raceCoordinator looks as if its a member function of your RunProgram 
class.    using the name without parenthesis is retrieving the address 
of the function, whereas it looks as if you intended to call the 
function instead.

Incidentally, having a member function whose name is the same as the 
class except with one letter in a different case is a poor design choice 
IMHO - member functions whose names match the class should normally be 
constructors - as a casual reader of the code, perhaps not looking too 
closely, most would expect RaceCoordinator::raceCoordinator() to be a 
default constructor
 




 9 Posts in Topic:
Help with Compile Error :)
Kush <kbubbar@[EMAIL P  2008-07-19 11:10:17 
Re: Help with Compile Error :)
Ben Cottrell <bench@[E  2008-07-19 20:26:14 
Re: Help with Compile Error :)
Kush <kbubbar@[EMAIL P  2008-07-19 20:37:03 
Re: Help with Compile Error :)
"Jim Langston"   2008-07-19 22:42:11 
Re: Help with Compile Error :)
ike@[EMAIL PROTECTED] (I  2008-07-20 06:50:17 
Re: Help with Compile Error :)
Kush <kbubbar@[EMAIL P  2008-07-20 05:32:41 
Re: Help with Compile Error :)
Kush <kbubbar@[EMAIL P  2008-07-20 05:39:27 
Re: Help with Compile Error :)
ike@[EMAIL PROTECTED] (I  2008-07-20 15:08:22 
Re: Help with Compile Error :)
Francis Glassborow <fr  2008-07-22 14:07:44 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
localhost-V2008-12-19 Fri Jan 9 5:48:29 PST 2009.