473,406 Members | 2,698 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,406 software developers and data experts.

Ultra-basic C++ question

I have a class called Manager, which I want to instantiate in my driver
class. It is in a file called Manager.cpp. Manager has no constructors set
up.

I also have a driver class and I want to create a Manager object called
manager in my main function of the driver class.

I used the code:

Manager manager;
However i get errors such as "Manager: undeclared identifier" and "syntax
error : missing ';' before indentifier 'manager'" when I try to compile.

What am I doing wrong?
Oct 12 '05 #1
12 1475
James wrote:
I have a class called Manager, which I want to instantiate in my driver
class. It is in a file called Manager.cpp. Manager has no constructors set
up.

I also have a driver class and I want to create a Manager object called
manager in my main function of the driver class.

I used the code:

Manager manager;
However i get errors such as "Manager: undeclared identifier" and "syntax
error : missing ';' before indentifier 'manager'" when I try to compile.

What am I doing wrong?


You need to put the class declaration in a header file (perhaps,
Manager.hpp) and then include it in other .cpp or .hpp files that need
it. For instance:

// File: Manager.hpp
class Manager
{
public:
void DoSomething();
// other functions and data members
};
// File: Manager.cpp
#include "Manager.hpp"

void Manager::DoSomething()
{
// ...
}
// File: Main.cpp
#include "Manager.hpp"

int main()
{
Manager manager;
manager.DoSomething();
// ...
return 0;
}

You could also define the functions of Manager in the header if they're
small. It might slow down compilation, however, if Manager.hpp is large
gets included many times throughout the project.

Cheers! --M

Oct 12 '05 #2

James wrote:
I have a class called Manager, which I want to instantiate in my driver
class. It is in a file called Manager.cpp. Manager has no constructors set
up.

I also have a driver class and I want to create a Manager object called
manager in my main function of the driver class.

I used the code:

Manager manager;
However i get errors such as "Manager: undeclared identifier" and "syntax
error : missing ';' before indentifier 'manager'" when I try to compile.

What am I doing wrong?


in driver.h

#include "Manager.h"

or show us your code

/dan

Oct 12 '05 #3
James wrote:
I have a class called Manager, which I want to instantiate in my driver
class. It is in a file called Manager.cpp. Manager has no constructors set
up.

I also have a driver class and I want to create a Manager object called
manager in my main function of the driver class.

I used the code:

Manager manager;
However i get errors such as "Manager: undeclared identifier" and "syntax
error : missing ';' before indentifier 'manager'" when I try to compile.

What am I doing wrong?


The file with the driver code has to somehow have the definition of the
'Manager' class available to it. The usual approach is to put the class
definition in a header file, like so

// this is 'Manager.h' file:
#ifndef MANAGER_H_INCLUDED // those are called 'double inclusion
#define MANAGER_H_INCLUDED // guards', read about them elsewhere

class Manager {
...
};

#endif
// end of 'Manager.h' file

then include that header in *both* the 'Manager.cpp' and the file where
the driver code is:

#include "Manager.h"
...

V
Oct 12 '05 #4
James wrote:
I have a class called Manager, which I want to instantiate in my
driver class. It is in a file called Manager.cpp. Manager has no
constructors set up.

I also have a driver class and I want to create a Manager object
called manager in my main function of the driver class.

I used the code:

Manager manager;
However i get errors such as "Manager: undeclared identifier" and
"syntax error : missing ';' before indentifier 'manager'" when I try
to compile.

What am I doing wrong?


You failed to present a complete, minimal program that produces the
problem. How can we comment on code you don't show us? Don't describe
your code, paste it in directly.

Brian
--
Please quote enough of the previous message for context. To do so from
Google, click "show options" and use the Reply shown in the expanded
header.
Oct 12 '05 #5
"Default User" <de***********@yahoo.com> wrote in message
news:3r************@individual.net...
James wrote:
I have a class called Manager, which I want to instantiate in my
driver class. It is in a file called Manager.cpp. Manager has no
constructors set up.

I also have a driver class and I want to create a Manager object
called manager in my main function of the driver class.

I used the code:

Manager manager;
However i get errors such as "Manager: undeclared identifier" and
"syntax error : missing ';' before indentifier 'manager'" when I try
to compile.

What am I doing wrong?


You failed to present a complete, minimal program that produces the
problem. How can we comment on code you don't show us? Don't describe
your code, paste it in directly.


The description I gave appears to have been enough, because it's been
answered in all three responses (except yours).

Thanks all.
Oct 12 '05 #6
James wrote:
"Default User" <de***********@yahoo.com> wrote in message
news:3r************@individual.net...

You failed to present a complete, minimal program that produces the
problem. How can we comment on code you don't show us? Don't
describe your code, paste it in directly.


The description I gave appears to have been enough, because it's been
answered in all three responses (except yours).

Thanks all.


Demonstrating merely that the people here are clever enough to deduce
what your problem was, not anything you did (copping an attitude
doesn't count).

Please the FAQ about how to post questions properly.
Brian
Oct 13 '05 #7
"Default User" <de***********@yahoo.com> wrote in message
news:3r************@individual.net...
James wrote:
"Default User" <de***********@yahoo.com> wrote in message
news:3r************@individual.net...
> You failed to present a complete, minimal program that produces the
> problem. How can we comment on code you don't show us? Don't
> describe your code, paste it in directly.


The description I gave appears to have been enough, because it's been
answered in all three responses (except yours).

Thanks all.


Demonstrating merely that the people here are clever enough to deduce
what your problem was, not anything you did (copping an attitude
doesn't count).


It didn't require anything "clever" to work out what I was asking.
Please the FAQ about how to post questions properly.


No, sorry don't have the time or need to.
Oct 13 '05 #8
James wrote:
"Default User" <de***********@yahoo.com> wrote in message
news:3r************@individual.net...

[snip]
Please the FAQ about how to post questions properly.


No, sorry don't have the time or need to.


Sigh. James, you just put the kiss-o-death on your posting
here. If you *won't* read the FAQ, why should anybody help
you? You should now change your screen name so others won't
know it's this person who couldn't bother with the FAQ.
Socks

Oct 13 '05 #9
"Puppet_Sock" <pu*********@hotmail.com> wrote in message
news:11*********************@g14g2000cwa.googlegro ups.com...
James wrote:
"Default User" <de***********@yahoo.com> wrote in message
news:3r************@individual.net...

[snip]
> Please the FAQ about how to post questions properly.


No, sorry don't have the time or need to.


Sigh. James, you just put the kiss-o-death on your posting
here. If you *won't* read the FAQ, why should anybody help
you? You should now change your screen name so others won't
know it's this person who couldn't bother with the FAQ.


Sigh. My handle is totally made-up and I change it every couple of days
anyway. I have no history or reputation to protect so a change of name means
nothing to me.

BTW Why is it these kind of newsgroups are full of self-important control
freaks? I appreciate the help that people give me, and the majority are
helpful and friendly, but some people *really* need to get a life.
Oct 13 '05 #10
James wrote:
[snip]
BTW Why is it these kind of newsgroups are full of self-important control
freaks?
I don't know. Why *do* you infest newsgroups?
I appreciate the help that people give me, and the majority are
helpful and friendly, but some people *really* need to get a life.


No. You don't appreciate the help people give you, else you'd
read the FAQ.
Socks

Oct 13 '05 #11
"Puppet_Sock" <pu*********@hotmail.com> wrote in message
news:11**********************@g47g2000cwa.googlegr oups.com...
<snip!>

Yawn. Grow up.
Oct 13 '05 #12
James wrote:
"Puppet_Sock" <pu*********@hotmail.com> wrote in message
news:11**********************@g47g2000cwa.googlegr oups.com...
<snip!>

Yawn. Grow up.


Nominated for SRPOTM.
Socks

Oct 14 '05 #13

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

Similar topics

2
by: Phillip Parr | last post by:
Hello, Recently submitting forms (specifically forms which have javascript attached to them with the submit function) has become very slow. The browser appears to sit there for seveal seconds...
5
by: Paul W | last post by:
I was recently assigned to build a database administration tool with an infragistics web grid UI. I am able to pull the data into a dataSet and bind it fine. However, when I attempted to use the...
0
by: Michael D. Reed | last post by:
I have a C++ program that I am trying to get to compile and link in VS2003. It is an old windows program that was built and maintained with older versions of VS and VC++. I made the necessary...
5
by: sam | last post by:
hi all, i continue to footle around on my spanking new ultra 20 (1.8GHz / Opteron Model 144), gradually trying to get to grips with python and unix both. the slow print time in IDLE had...
2
by: zafar | last post by:
in table i have a field for date and time, but in grid only date is shown, where i want to display the time only ( i am using ultra grid tool of infragestrics),, thanx if any body can help me for...
3
by: Sarahb1337 | last post by:
Hi all, I have two tables that I'm trying to display in a Master Detail fashion in an Infragistics UltraGrid. I added both tables to a dataset and added a datarelation between the two tables...
15
by: CMOS | last post by:
one of the projects im working in currently requires use of ultra large sized maps, lists, vector, etc. (basically stl containers). Sizes might grow up to 1000 Million entries. since it is...
0
by: faizalahmd | last post by:
I would like to have paging as well as sorting in a infragistics ultra web grid control .. regards, Faizal Ahmed
0
by: bwljgbwn | last post by:
nero 7 ultra edition crack http://cracks.12w.net F R E E
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
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...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.