Ok, here's the deal. I have a nice class definition and a whole bunch
of inline functions to go along with it in the same file. My question
is, do I need an implementation file for the class, even though I have
an inline for every single function? Or can I just use the class and
it's inlines as a header file for programs that actually use the class
and defined functions?
While I'm here I might as well ask this one too. Here is a function
that I have in the same class that I was talking about above:
inline int Startup(void) {
short quit;
std::cout << "Welcome to the Agent system Neo\n"; IO stuff
std::cout << "Do you wish to continue?(y/n)\n";
while (quit != 'y') && (quit != 'Y')
(quit != 'n') && (quit != 'N') {
if (std::cin << 'y') {
std::cout << "Please wait\n";
} else (std::cin << 'n') {
Close(); // calls Close() function
}
This won't compile. The gcc says that I can't use the
short quit;
because it hasn't been declared. I don't have to declare it private
right? I tried that and it didn't work, I got the same error. How is
the loop structure, am I doing something wrong here? I also get a
parse error before 'quit' in the while loop just before the bitwise
'and' operator.
Thanks in advance for any help, it is greatly appreciated.
neo88 29 1790
neo88 wrote: inline int Startup(void) { short quit; std::cout << "Welcome to the Agent system Neo\n"; IO stuff std::cout << "Do you wish to continue?(y/n)\n"; while (quit != 'y') && (quit != 'Y') (quit != 'n') && (quit != 'N') { if (std::cin << 'y') { std::cout << "Please wait\n"; } else (std::cin << 'n') { Close(); // calls Close() function }
This won't compile. The gcc says that I can't use the short quit; because it hasn't been declared.
Come on now. Didn't it really say "initialize d"?
Is it right? What value do you think "quit" has
when you first use it?
--
Regards,
Buster.
neo88 wrote: inline int Startup(void) { short quit; std::cout << "Welcome to the Agent system Neo\n"; IO stuff std::cout << "Do you wish to continue?(y/n)\n"; while (quit != 'y') && (quit != 'Y') (quit != 'n') && (quit != 'N') { if (std::cin << 'y') { std::cout << "Please wait\n"; } else (std::cin << 'n') { Close(); // calls Close() function }
This won't compile. The gcc says that I can't use the short quit; because it hasn't been declared.
Come on now. Didn't it really say "initialize d"?
Is it right? What value do you think "quit" has
when you first use it?
--
Regards,
Buster.
"neo88" <so****@truevin e.net> wrote Ok, here's the deal. I have a nice class definition and a whole bunch of inline functions to go along with it in the same file. My question is, do I need an implementation file for the class, even though I have an inline for every single function? Or can I just use the class and it's inlines as a header file for programs that actually use the class and defined functions?
You could get away with just the header file, but it's good practice to have
a corresponding .cpp file, even if all it does is include the header file as
a sanity check. As your project grows, you might find that some functions,
old or new, might be better placed out-of-line or you might want to add
version information to the files in static strings or compile-time checks or
static support functions, etc.. Any changes you make in the future will then
affect how your libraries and/or applications are built. Also, unless you
comment it clearly, someone who only sees the hearder file might waste time
looking for the .cpp file. There's value in a consistent build structure.
Claudio Puviani
"neo88" <so****@truevin e.net> wrote Ok, here's the deal. I have a nice class definition and a whole bunch of inline functions to go along with it in the same file. My question is, do I need an implementation file for the class, even though I have an inline for every single function? Or can I just use the class and it's inlines as a header file for programs that actually use the class and defined functions?
You could get away with just the header file, but it's good practice to have
a corresponding .cpp file, even if all it does is include the header file as
a sanity check. As your project grows, you might find that some functions,
old or new, might be better placed out-of-line or you might want to add
version information to the files in static strings or compile-time checks or
static support functions, etc.. Any changes you make in the future will then
affect how your libraries and/or applications are built. Also, unless you
comment it clearly, someone who only sees the hearder file might waste time
looking for the .cpp file. There's value in a consistent build structure.
Claudio Puviani
neo88 wrote: inline int Startup(void) { short quit; std::cout << "Welcome to the Agent system Neo\n"; IO stuff std::cout << "Do you wish to continue?(y/n)\n"; while (quit != 'y') && (quit != 'Y') (quit != 'n') && (quit != 'N') { if (std::cin << 'y') { std::cout << "Please wait\n"; } else (std::cin << 'n') { Close(); // calls Close() function }
[...] I also get a parse error before 'quit' in the while loop just before the bitwise 'and' operator.
The entire condition for the while loop has to be parenthesized:
while ((quit != 'y') && (quit != 'Y') &&
(quit != 'n') && (quit != 'N')) // ...
(You still need to initialize "quit" first though. Hint: there's
no way for you to do that and have the whole function still make
sense. You should remove all of the lines with "quit" in them.)
Regarding "if (std::cin << 'y')": you can't do it like that, I'm
afraid. The following is legal.
// ...
char c;
if (std::cin >> c)
{
if (c == 'y')
{
std::cout << "Please wait\n";
}
else if (c == 'n')
{
Close (); // The comment "calls Close() function"
// is worse than useless.
}
else
{
// Deal with other possible inputs.
}
}
else
{
// Deal with an input problem.
}
// ...
--
Regards,
Buster.
"neo88" <so****@truevin e.net> wrote in message
news:6a******** *************** ***@posting.goo gle.com... While I'm here I might as well ask this one too. Here is a function that I have in the same class that I was talking about above:
inline int Startup(void) {
If you include the implementation code here, there is no need for the
"inline" directive.
short quit; std::cout << "Welcome to the Agent system Neo\n"; IO stuff
Missing comment marks here, before "IO stuff"? (Lousy comment, by the way.)
std::cout << "Do you wish to continue?(y/n)\n";
while (quit != 'y') && (quit != 'Y') (quit != 'n') && (quit != 'N') {
Typo? There should be another "&&" between those two lines. Is there?
And why are you comparing a short (quit) against a char ('y', etc.)? Maybe
that's what that error means..there is no variable called quit that matches
the comparison against a char? (Just a guess.)
Also, the *entire* boolean expression has to be in parentheses, not just the
individual sub-expressions.
if (std::cin << 'y') { std::cout << "Please wait\n"; } else (std::cin << 'n') { Close(); // calls Close() function
Another strange comment. Pretty obvious that Close() calls Close(), isn't
it?
But why are you calling Close() (whatever that is) inside your loop? Do you
want to "close" every time through the loop? And is there any matching Open
function?
}
Where's the rest of it? You're two closing braces short here.
This won't compile. The gcc says that I can't use the short quit; because it hasn't been declared.
Where does quit ever get a value assigned to it?
I don't have to declare it private right? I tried that and it didn't work, I got the same error. How is the loop structure, am I doing something wrong here? I also get a parse error before 'quit' in the while loop just before the bitwise 'and' operator.
That's a boolean operator, not a bitwise operator. The bitwise operator is
&, not &&.
Thanks in advance for any help, it is greatly appreciated. neo88
neo88 wrote: inline int Startup(void) { short quit; std::cout << "Welcome to the Agent system Neo\n"; IO stuff std::cout << "Do you wish to continue?(y/n)\n"; while (quit != 'y') && (quit != 'Y') (quit != 'n') && (quit != 'N') { if (std::cin << 'y') { std::cout << "Please wait\n"; } else (std::cin << 'n') { Close(); // calls Close() function }
[...] I also get a parse error before 'quit' in the while loop just before the bitwise 'and' operator.
The entire condition for the while loop has to be parenthesized:
while ((quit != 'y') && (quit != 'Y') &&
(quit != 'n') && (quit != 'N')) // ...
(You still need to initialize "quit" first though. Hint: there's
no way for you to do that and have the whole function still make
sense. You should remove all of the lines with "quit" in them.)
Regarding "if (std::cin << 'y')": you can't do it like that, I'm
afraid. The following is legal.
// ...
char c;
if (std::cin >> c)
{
if (c == 'y')
{
std::cout << "Please wait\n";
}
else if (c == 'n')
{
Close (); // The comment "calls Close() function"
// is worse than useless.
}
else
{
// Deal with other possible inputs.
}
}
else
{
// Deal with an input problem.
}
// ...
--
Regards,
Buster.
"Howard" <al*****@hotmai l.com> wrote in message
news:c5******** @dispatch.conce ntric.net... if (std::cin << 'y') { std::cout << "Please wait\n"; } else (std::cin << 'n') {
Oh, and I missed those lines. You can't stream data into constant
expressions. I take it you wanted to enter the data into your quit
variable, since that's what you're using to compare againt in your while
loop. You need to stream into a variable.
Howard
"neo88" <so****@truevin e.net> wrote in message
news:6a******** *************** ***@posting.goo gle.com... While I'm here I might as well ask this one too. Here is a function that I have in the same class that I was talking about above:
inline int Startup(void) {
If you include the implementation code here, there is no need for the
"inline" directive.
short quit; std::cout << "Welcome to the Agent system Neo\n"; IO stuff
Missing comment marks here, before "IO stuff"? (Lousy comment, by the way.)
std::cout << "Do you wish to continue?(y/n)\n";
while (quit != 'y') && (quit != 'Y') (quit != 'n') && (quit != 'N') {
Typo? There should be another "&&" between those two lines. Is there?
And why are you comparing a short (quit) against a char ('y', etc.)? Maybe
that's what that error means..there is no variable called quit that matches
the comparison against a char? (Just a guess.)
Also, the *entire* boolean expression has to be in parentheses, not just the
individual sub-expressions.
if (std::cin << 'y') { std::cout << "Please wait\n"; } else (std::cin << 'n') { Close(); // calls Close() function
Another strange comment. Pretty obvious that Close() calls Close(), isn't
it?
But why are you calling Close() (whatever that is) inside your loop? Do you
want to "close" every time through the loop? And is there any matching Open
function?
}
Where's the rest of it? You're two closing braces short here.
This won't compile. The gcc says that I can't use the short quit; because it hasn't been declared.
Where does quit ever get a value assigned to it?
I don't have to declare it private right? I tried that and it didn't work, I got the same error. How is the loop structure, am I doing something wrong here? I also get a parse error before 'quit' in the while loop just before the bitwise 'and' operator.
That's a boolean operator, not a bitwise operator. The bitwise operator is
&, not &&.
Thanks in advance for any help, it is greatly appreciated. neo88 This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Bozo Schmozo |
last post by:
Greetings!
I've searched groups.google.com already to see if I can determine if
using PHP/MySQL (if needed) for a web site I wish to develop. As the
subject indicated, it will be a content based site with videos - NO,
it's not a porn site though.
I thought that I'd list the key requirements/specifications for my web
site below and was wondering if some of you'd be so kind as to provide
your thoughts on each and comment on them with...
|
by: lawrence |
last post by:
Sorry for the dumb question but I'm new to Javascript. I wrote this
script hoping to animate some div blocks on a page. You can see the
page here: http://www.keymedia.biz/demo.htm
Can anyone tell me why these DIVs don't drift to the left as they are
supposed to?
<script language="javascript">
|
by: Tony Johansson |
last post by:
Hello Experts!
I have some questions about inheritance that I want to have an answer to.
It says "Abstract superclasses define a behavioral pattern without
specifying the implementation"
I know that an abstract class doesn't have any implementaion even if a
default implementatiion can be supplied for pure virtual methods.
What does it actually mean with saying that an Abstract superclasses define
a behavioral pattern?
|
by: MSFCLIPPER |
last post by:
there are now new open source project presents new programming style
design / paradigm vs OOP
we invite all programmers to participate in this project
project site : www.sourceforge.net/projects/doublesvsoop
Greetings
Eng. Mahmoud
the author of DoubleS ( Super Server Programming Style)
|
by: iTISTIC |
last post by:
Developing a new app and am trying to make this my first truly
OOP/3-Tier app. I understand the principles of the presentation,
business, and data layers. I do, however, have some questions on where
certain functionality should be placed and how some things should be
implemented.
Let's use a simple example such as an application to manage customer
records (customer_id, first_name, last_name). I'd have a Customer
business object with ID,...
| |
by: M.Siler |
last post by:
Let me clarify from my last post. I am not using these 4 questions as the
sole screening method. Currently in, the Tampa Bay area (Florida) there is
an extreme shortage of C# developers. We have utilized just about every
method known to man to find candidates, including employment firms (which I
do not like to use, but when you're back in against the proverbial wall).
With the employment firms they will send over just about anyone. So after...
|
by: Nemisis |
last post by:
Hi everyone,
I have 2 classes, Company and Contact, a company can have 1 or more
contacts. A contact can only be in one company.
I have created a Company class object that contains all the properties
for my company. I have created a CompanyFactory class that has the
methods to Create, Retrieve, Update and Delete a company.
I have done the same for the Contact class and ContactFactory.
|
by: Nemisis |
last post by:
Hi everyone,
I have 2 classes, Company and Contact, a company can have 1 or more
contacts. A contact can only be in one company.
I have created a Company class object that contains all the properties
for my company. I have created a CompanyFactory class that has the
methods to Create, Retrieve, Update and Delete a company.
I have done the same for the Contact class and ContactFactory.
|
by: Nemisis |
last post by:
Hi everyone, i have currently got a classic asp web application and am
wanting to upgrade it to asp.net 2.0, and also take advantage of OOP.
Our current application is not using OOP so you can imagine how hard it
is too upgrade.
I have read documentation all over the net, but still have some
questions (if anyone has any good documentation, i would love to read
it!!). i should warn you the questions maybe stupid/easy but i just
need...
|
by: Inso Reiges |
last post by:
Hi,
I`m new to C++ and OOP in general and i come from long-time C mindset.
So i have some style questions.
I have a class that needs to be initialized by over nine parameters.
So i decided to put this mess into some kind of an object (here by
object i don`t mean a class instance) and pass it to constructor. In C
such thing would usually be done by filling out a struct. Should i use
an object (class instance) in C++ or is it ok to use...
|
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
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 then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
|
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |