473,473 Members | 2,155 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

another question

hii,

////i have three headers

struct activities
{
string exercises;
int time;
};

class Gymnasium
{
protected:
activities gymarray[5];
int gymlength;
public:
void set(string,int);
void getActivities(string&,int&)const;
double calories();
void print();
Gymnasium(string, int );
};
++++++++++++++++++++++++++++++++++++
struct meals
{
string food;
int portion;

};

class Nutrition
{
protected:
meals nutritionarray[5];
int nutritionLength;

public:
void set(string , int);
void getMeals(string& , int&)const;
void print();
Nutrition(string , int);
double calories();
};
+++++++++++++++++++++++++++++++++++++++
class Regime
{
public:
void set(string,int ,string,int);
void print();
Regime(string ,int,string,int);
double calories();

private:
Gymnasium exercisePlan ;
Nutrition dietPlan;
};

/////The implitation of the set function of the class Regime how
should it be
///i did this
void Regime::set(string ex,int t,string f,int p)
{
Gymnasium::set(ex,t);
Nutrition::set(f,p);
}
//////but it gives me error
//// and if i want to subtract the calories in the Gymnasium from the
calories in the Nutrition ,like
double Regime::calories()
{
int After;
After=Gymnasium::calories()- Nutrition::calories();

return After;
}
////it gives me an error that it is illegal call of non-static member
function,why ? what should i do then ??

Oct 27 '07 #1
1 1423
On 2007-10-27 06:02, CuTe_Engineer wrote:
hii,

////i have three headers

struct activities
{
string exercises;
int time;
};

class Gymnasium
{
protected:
activities gymarray[5];
int gymlength;
public:
void set(string,int);
void getActivities(string&,int&)const;
double calories();
void print();
Gymnasium(string, int );
};
++++++++++++++++++++++++++++++++++++
struct meals
{
string food;
int portion;

};

class Nutrition
{
protected:
meals nutritionarray[5];
int nutritionLength;

public:
void set(string , int);
void getMeals(string& , int&)const;
void print();
Nutrition(string , int);
double calories();
};
+++++++++++++++++++++++++++++++++++++++
class Regime
{
public:
void set(string,int ,string,int);
void print();
Regime(string ,int,string,int);
double calories();

private:
Gymnasium exercisePlan ;
Nutrition dietPlan;
};

/////The implitation of the set function of the class Regime how
should it be
///i did this
void Regime::set(string ex,int t,string f,int p)
{
Gymnasium::set(ex,t);
Nutrition::set(f,p);
}
//////but it gives me error
//// and if i want to subtract the calories in the Gymnasium from the
calories in the Nutrition ,like
double Regime::calories()
{
int After;
After=Gymnasium::calories()- Nutrition::calories();

return After;
}
////it gives me an error that it is illegal call of non-static member
function,why ? what should i do then ??
You need to learn to separate a class from an instance of that class,
this is a fundamental knowledge and you will not get far without it.

void Regime::set(string ex,int t,string f,int p)
{
exercisePlan.set(ex,t);
dietPlan.set(f,p);
}

double Regime::calories()
{
double After;
After = dietPlan.calories() - exercisePlan.calories()

return After;
}

--
Erik Wikström
Oct 27 '07 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: fig000 | last post by:
Hi, I'm relatively new to Javascript so please bear with me on what might sound like silly questions. This is what I want to do: I'm working in classic asp (I have to for this project). I...
6
by: anon | last post by:
Post Forwarding question...... For this control below, <asp:Button runat="server" PostTargetUrl="page2.aspx" /> The Attribute: PostTargetUrl="page2.aspx" Is this PostTargetUrl Attribute...
2
by: terence.parker | last post by:
I am often faced with the dilemma of whether to use a JOIN query across three tables in order to grab a bunch of results - or whether to create another table to represent what I want. The latter is...
0
by: Sebastian Hiller | last post by:
Hello, i'm new to .Net (i'm using VB as language and i'm working in the code-behind mode) and i can't solve the following problem: I have a WebForm and want to Add a UserControl...
3
by: Brad | last post by:
I have another hopefully simple question. I am so used to writing VB .Net windows apps that there are some things in ASP .Net that just does not easily cross over. I know how to pass variables to...
27
by: Javier Martinez | last post by:
Hi I have asp application in a machine with a virtual directory referring a shared directory in another machine When I try to load any aspx page of my portal I get the following error: ...
17
by: Eric_Dexter | last post by:
def simplecsdtoorc(filename): file = open(filename,"r") alllines = file.read_until("</CsInstruments>") pattern1 = re.compile("</") orcfilename = filename + "orc" for line in alllines: if not...
24
by: David Mathog | last post by:
On a Solaris 8 system if a user "joe" logs in, for instance via ssh, cuserid() returns "joe". That's the expected behavior and so far so good. However if that user then does: % su - sally ...
13
by: shookim | last post by:
I don't care how one suggests I do it, but I've been searching for days on how to implement this concept. I'm trying to use some kind of grid control (doesn't have to be a grid control, whatever...
4
by: MichaelK | last post by:
Hello. I have all data already collected on the current page? I want to open another window with the form, fill the fields and submit that form. So basically the question is how can I fill all...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.