473,394 Members | 1,951 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

What's Wrong with these code?

I get this error message:

Error E2235 EX3.CPP 60: Member function must be called or its address taken in
function main()

From these code:

#include<iostream.h>

class Employee {
public:
int GetAge();
void SetAge(int age);
int GetYearsOfService();
void SetYearsOfService(int yearsOfService);
int GetSalary();
void SetSalary(int Salary);

private:
int myage;
int myyearsOfService;
int mySalary;
};

int Employee::GetAge()
{
return myage;
}

void Employee::SetAge(int age)
{
myage = age;
}

int Employee::GetYearsOfService()
{
return myyearsOfService;
}

void Employee::SetYearsOfService(int yearsOfService)
{
myyearsOfService = yearsOfService;
}

int Employee::GetSalary()
{
return mySalary;
}

void Employee::SetSalary(int Salary)
{
mySalary = Salary;
}

void main (void)
{
Employee John;
Employee Sally;
John.SetAge(30);
John.SetYearsOfService(5);
John.SetSalary(50000);

Sally.SetAge(32);
Sally.SetYearsOfService(8);
Sally.SetSalary(40000);

cout << "John is " << John.GetAge << " years old and he has been with";
cout << " the firm for " << John.GetYearsOfService << " years\n";
cout << "John earns $" << John.GetSalary << " dollars a year.\n\n";

cout << "Sally is " << Sally.GetAge << "years old and she has been with";
cout << " the firm for " << Sally.GetYearsOfService << " years\n";
cout << "Sally earns $" << Sally.GetSalary << " dollars a year\n\n";
}

What's wrong?

Thanks!
Jul 22 '05 #1
2 2886
Richard wrote:
I get this error message:

Error E2235 EX3.CPP 60: Member function must be called or its address taken in
function main()

From these code:

#include<iostream.h>

class Employee {
public:
int GetAge();
void SetAge(int age);
int GetYearsOfService();
void SetYearsOfService(int yearsOfService);
int GetSalary();
void SetSalary(int Salary);

private:
int myage;
int myyearsOfService;
int mySalary;
};

int Employee::GetAge()
{
return myage;
}

void Employee::SetAge(int age)
{
myage = age;
}

int Employee::GetYearsOfService()
{
return myyearsOfService;
}

void Employee::SetYearsOfService(int yearsOfService)
{
myyearsOfService = yearsOfService;
}

int Employee::GetSalary()
{
return mySalary;
}

void Employee::SetSalary(int Salary)
{
mySalary = Salary;
}

void main (void)
{
Employee John;
Employee Sally;
John.SetAge(30);
John.SetYearsOfService(5);
John.SetSalary(50000);

Sally.SetAge(32);
Sally.SetYearsOfService(8);
Sally.SetSalary(40000);

cout << "John is " << John.GetAge << " years old and he has been with";
cout << " the firm for " << John.GetYearsOfService << " years\n";
cout << "John earns $" << John.GetSalary << " dollars a year.\n\n";

cout << "Sally is " << Sally.GetAge << "years old and she has been with";
cout << " the firm for " << Sally.GetYearsOfService << " years\n";
cout << "Sally earns $" << Sally.GetSalary << " dollars a year\n\n";
}

What's wrong?


You forgot the brackets () after the John.GetAge,
John.GetYearsOfService...etc.

--
Peter van Merkerk
peter.van.merkerk(at)dse.nl
Jul 22 '05 #2
ri***********@yahoo.com (Richard) writes:
I get this error message: Error E2235 EX3.CPP 60: Member function must be called or its address taken in
...
cout << "John is " << John.GetAge << " years old and he has been with";
... What's wrong?

When you call a fn that doesn't take args, you still need the (), so
"John.GetAge" should be "John.GetAge()", etc.

Also main shouldn't return void. And try to use
#include<iostream>
if your set-up allows it.
Jul 22 '05 #3

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

Similar topics

125
by: Sarah Tanembaum | last post by:
Beside its an opensource and supported by community, what's the fundamental differences between PostgreSQL and those high-price commercial database (and some are bloated such as Oracle) from...
5
by: titan0111 | last post by:
#include<iostream> #include<iomanip> #include<cstring> #include<fstream> using namespace std; class snowfall { private: int ft;
72
by: E. Robert Tisdale | last post by:
What makes a good C/C++ programmer? Would you be surprised if I told you that it has almost nothing to do with your knowledge of C or C++? There isn't much difference in productivity, for...
121
by: typingcat | last post by:
First of all, I'm an Asian and I need to input Japanese, Korean and so on. I've tried many PHP IDEs today, but almost non of them supported Unicode (UTF-8) file. I've found that the only Unicode...
56
by: Cherrish Vaidiyan | last post by:
Frinds, Hope everyone is doing fine.i feel pointers to be the most toughest part in C. i have just completed learning pointers & arrays related portions. I need to attend technical interview on...
46
by: Keith K | last post by:
Having developed with VB since 1992, I am now VERY interested in C#. I've written several applications with C# and I do enjoy the language. What C# Needs: There are a few things that I do...
13
by: Jason Huang | last post by:
Hi, Would someone explain the following coding more detail for me? What's the ( ) for? CurrentText = (TextBox)e.Item.Cells.Controls; Thanks. Jason
4
by: Rachel Suddeth | last post by:
What is the difference between a managed/unmanaged resource, and how do you tell which is which? I'm trying to understand how to write some Dispose() methods, and we are supposed to put code that...
669
by: Xah Lee | last post by:
in March, i posted a essay “What is Expressiveness in a Computer Language”, archived at: http://xahlee.org/perl-python/what_is_expresiveness.html I was informed then that there is a academic...
30
by: Bill Reid | last post by:
#define MAX_VALUES 64 typedef struct { unsigned value_1; double value_2; double value_3; double value_4; } VALUES; typedef struct {
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
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...
0
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...

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.