Discussion:
Q2 Compilation errors
(too old to reply)
Dustin Fader
2011-07-02 19:09:53 UTC
Permalink
I keep getting the following errors when I try to compile my files for Q2:

q2.cc:28:error: 'cout' was not declared in this scope


and

q2.cc:55: error: expected constructor, destructor, or type conversion
before '&' token


and the relevant lines producing these errors are :

28: cout << "test";

and

55: istream &operator<<( istream &is, Complex &c ) {


I've included <iostream> in my h. and driver file just as in the example
code, so I'm not quite sure what is causing these errors...can anybody
assist?

P.S. My code for 55 doesn't actually contain the Complex struct, but
didn't want to include my actual implementation just incase...
Jeremy Roman
2011-07-02 19:17:50 UTC
Permalink
Post by Dustin Fader
q2.cc:28:error: 'cout' was not declared in this scope
and
q2.cc:55: error: expected constructor, destructor, or type conversion
before '&' token
28: cout << "test";
and
55: istream &operator<<( istream &is, Complex &c ) {
I've included <iostream> in my h. and driver file just as in the example
code, so I'm not quite sure what is causing these errors...can anybody
assist?
P.S. My code for 55 doesn't actually contain the Complex struct, but
didn't want to include my actual implementation just incase...
You have likely forgotten to include the line:

using namespace std;

A number of things in the C++ core library are contained in the std
namespace; this line "imports" these into the current namespace.
Alternatively, you could say "std::cout" instead of "cout",
"std::string" instead of "string", and so on.
--
Jeremy Roman
Student, Computer Science
University of Waterloo
Dustin Fader
2011-07-02 19:26:23 UTC
Permalink
Post by Jeremy Roman
Post by Dustin Fader
q2.cc:28:error: 'cout' was not declared in this scope
and
q2.cc:55: error: expected constructor, destructor, or type conversion
before '&' token
28: cout << "test";
and
55: istream &operator<<( istream &is, Complex &c ) {
I've included <iostream> in my h. and driver file just as in the example
code, so I'm not quite sure what is causing these errors...can anybody
assist?
P.S. My code for 55 doesn't actually contain the Complex struct, but
didn't want to include my actual implementation just incase...
using namespace std;
A number of things in the C++ core library are contained in the std
namespace; this line "imports" these into the current namespace.
Alternatively, you could say "std::cout" instead of "cout",
"std::string" instead of "string", and so on.
Nope, I've included that line in both my implementation and driver
files. I also tried doing std::cout, but got the error:

'cout' is not a member of 'std'
Jeremy Roman
2011-07-02 19:42:32 UTC
Permalink
Post by Dustin Fader
Post by Jeremy Roman
Post by Dustin Fader
q2.cc:28:error: 'cout' was not declared in this scope
and
q2.cc:55: error: expected constructor, destructor, or type conversion
before '&' token
28: cout << "test";
and
55: istream &operator<<( istream &is, Complex &c ) {
I've included <iostream> in my h. and driver file just as in the example
code, so I'm not quite sure what is causing these errors...can anybody
assist?
P.S. My code for 55 doesn't actually contain the Complex struct, but
didn't want to include my actual implementation just incase...
using namespace std;
A number of things in the C++ core library are contained in the std
namespace; this line "imports" these into the current namespace.
Alternatively, you could say "std::cout" instead of "cout",
"std::string" instead of "string", and so on.
Nope, I've included that line in both my implementation and driver
'cout' is not a member of 'std'
If you have these two lines in the file and are still getting that
error, I'm not sure what's happening.

#include <iostream>
using namespace std;

That's the best I can do; sorry. Best of luck figuring it out.
--
Jeremy Roman
Student, Computer Science
University of Waterloo
Dustin Fader
2011-07-02 20:02:07 UTC
Permalink
Post by Jeremy Roman
Post by Dustin Fader
Post by Jeremy Roman
Post by Dustin Fader
q2.cc:28:error: 'cout' was not declared in this scope
and
q2.cc:55: error: expected constructor, destructor, or type conversion
before '&' token
28: cout << "test";
and
55: istream &operator<<( istream &is, Complex &c ) {
I've included <iostream> in my h. and driver file just as in the example
code, so I'm not quite sure what is causing these errors...can anybody
assist?
P.S. My code for 55 doesn't actually contain the Complex struct, but
didn't want to include my actual implementation just incase...
using namespace std;
A number of things in the C++ core library are contained in the std
namespace; this line "imports" these into the current namespace.
Alternatively, you could say "std::cout" instead of "cout",
"std::string" instead of "string", and so on.
Nope, I've included that line in both my implementation and driver
'cout' is not a member of 'std'
If you have these two lines in the file and are still getting that
error, I'm not sure what's happening.
#include <iostream>
using namespace std;
That's the best I can do; sorry. Best of luck figuring it out.
Ya, it seems really strange. I include the .h right away which includes
iostream, and then do the 'using namespace std', but for some reason
it's acting as if iostream is not included...I'm thinking I might have
to restart from a blank file.

Thanks anyways though.
Terry Anderson
2011-07-02 21:28:51 UTC
Permalink
Dustin, send me an email with all of your .cc and .h files attached for
this question. I'll have a look at them and can hopefully offer some
more insight into the problem.
--
Terry Anderson
CS 246 Instructor
Post by Dustin Fader
Post by Jeremy Roman
Post by Dustin Fader
Post by Jeremy Roman
Post by Dustin Fader
q2.cc:28:error: 'cout' was not declared in this scope
and
q2.cc:55: error: expected constructor, destructor, or type conversion
before '&' token
28: cout << "test";
and
55: istream &operator<<( istream &is, Complex &c ) {
I've included <iostream> in my h. and driver file just as in the example
code, so I'm not quite sure what is causing these errors...can anybody
assist?
P.S. My code for 55 doesn't actually contain the Complex struct, but
didn't want to include my actual implementation just incase...
using namespace std;
A number of things in the C++ core library are contained in the std
namespace; this line "imports" these into the current namespace.
Alternatively, you could say "std::cout" instead of "cout",
"std::string" instead of "string", and so on.
Nope, I've included that line in both my implementation and driver
'cout' is not a member of 'std'
If you have these two lines in the file and are still getting that
error, I'm not sure what's happening.
#include <iostream>
using namespace std;
That's the best I can do; sorry. Best of luck figuring it out.
Ya, it seems really strange. I include the .h right away which includes
iostream, and then do the 'using namespace std', but for some reason it's
acting as if iostream is not included...I'm thinking I might have to restart
from a blank file.
Thanks anyways though.
Muhammad tauqir
2011-07-04 20:24:44 UTC
Permalink
Have you included the standard library?

#include <cstdlib>

should do!

Regards,
Muhammad Tauqir
Post by Dustin Fader
Post by Jeremy Roman
Post by Dustin Fader
Post by Jeremy Roman
Post by Dustin Fader
q2.cc:28:error: 'cout' was not declared in this scope
and
q2.cc:55: error: expected constructor, destructor, or type conversion
before '&' token
28: cout << "test";
and
55: istream &operator<<( istream &is, Complex &c ) {
I've included <iostream> in my h. and driver file just as in the example
code, so I'm not quite sure what is causing these errors...can anybody
assist?
P.S. My code for 55 doesn't actually contain the Complex struct, but
didn't want to include my actual implementation just incase...
using namespace std;
A number of things in the C++ core library are contained in the std
namespace; this line "imports" these into the current namespace.
Alternatively, you could say "std::cout" instead of "cout",
"std::string" instead of "string", and so on.
Nope, I've included that line in both my implementation and driver
'cout' is not a member of 'std'
If you have these two lines in the file and are still getting that
error, I'm not sure what's happening.
#include <iostream>
using namespace std;
That's the best I can do; sorry. Best of luck figuring it out.
Ya, it seems really strange. I include the .h right away which includes
iostream, and then do the 'using namespace std', but for some reason
it's acting as if iostream is not included...I'm thinking I might have
to restart from a blank file.
Thanks anyways though.
Dustin Fader
2011-07-05 01:12:26 UTC
Permalink
Nope, but that wasn't what was causing the error. It seems like it was
just some strange behaviour because after copying the file to an
external location, removing it from my student environment, and then
copying it back over, it compiled successfully :S
Post by Muhammad tauqir
Have you included the standard library?
#include <cstdlib>
should do!
Regards,
Muhammad Tauqir
Post by Dustin Fader
Post by Jeremy Roman
Post by Dustin Fader
Post by Jeremy Roman
Post by Dustin Fader
I keep getting the following errors when I try to compile my files
for
q2.cc:28:error: 'cout' was not declared in this scope
and
q2.cc:55: error: expected constructor, destructor, or type conversion
before '&' token
28: cout << "test";
and
55: istream &operator<<( istream &is, Complex &c ) {
I've included <iostream> in my h. and driver file just as in the example
code, so I'm not quite sure what is causing these errors...can anybody
assist?
P.S. My code for 55 doesn't actually contain the Complex struct, but
didn't want to include my actual implementation just incase...
using namespace std;
A number of things in the C++ core library are contained in the std
namespace; this line "imports" these into the current namespace.
Alternatively, you could say "std::cout" instead of "cout",
"std::string" instead of "string", and so on.
Nope, I've included that line in both my implementation and driver
'cout' is not a member of 'std'
If you have these two lines in the file and are still getting that
error, I'm not sure what's happening.
#include <iostream>
using namespace std;
That's the best I can do; sorry. Best of luck figuring it out.
Ya, it seems really strange. I include the .h right away which includes
iostream, and then do the 'using namespace std', but for some reason
it's acting as if iostream is not included...I'm thinking I might have
to restart from a blank file.
Thanks anyways though.
Loading...