Chocolate Kitty Posted February 3, 2014 Share Posted February 3, 2014 having a bit of an issue with getting this to compile, specifically because of this error [spoiler=code] // Program file: ratdrive.cpp #include <iostream> #include <iomanip> #include <cstdlib> #include "rational.h" using namespace.std; int main() // testing rational class { rational r1, r2, r3, r4; cout << "Enter the first number (<integer>/<integer>): "; cin >> r1; cout << "Enter the second number (<integer>/<integer>): "; cin >> r2; cout << "Enter the third number (<integer>/<integer>): "; cin >> r3; r4 = r1 + r2 + r3; // test sum cout << "The sum of your three numbers is " << r4 << endl; return 0; } [spoiler=error] Line 9 error: expected identifier before '.' token error: expected ';' before '.' token error: expected unqualified-id before '.' token any help? this is the client code, as far as I know, the other files are 100% fine(I can post them if someone wants to look at them) Quote Link to comment Share on other sites More sharing options...
Balcerzak Posted February 3, 2014 Share Posted February 3, 2014 using namespace.std;should be using namespace std;Also, using declarations are bad practice unless you really need them. Especially for whole namespaces. A better approach would be using std::cout; using std::cin;or better yet, just every time you have a cout, just do std::coutimo, and iirc, ofc Quote Link to comment Share on other sites More sharing options...
Chocolate Kitty Posted February 3, 2014 Author Share Posted February 3, 2014 oh damn it why do i have a period there thanks and i'll keep that in mind, thanks Quote Link to comment Share on other sites More sharing options...
Balcerzak Posted February 3, 2014 Share Posted February 3, 2014 oh damn it why do i have a period there thanks and i'll keep that in mind, thanks It's mostly just to learn good habits for when you have to include your files and are planning on using multiple namespaces. If one of your includes declares a namespace, but you forget, and then your main tries to do other namespace stuff, well, it can get messy. At least that's how I remember it being explained. Quote Link to comment Share on other sites More sharing options...
Aleph Posted February 3, 2014 Share Posted February 3, 2014 or better yet, just every time you have a cout, just do std::cout this, so much god I hate when people import * from foo in python or this C++ equivalent. Run it through an obfuscator and hit me over the head with a heavy book ffs, it's the same thing. Quote Link to comment Share on other sites More sharing options...
Zanarkin Posted February 3, 2014 Share Posted February 3, 2014 god I hate when people import * from foo in python there are better ways to import things to python? Do tell. Quote Link to comment Share on other sites More sharing options...
Aleph Posted February 3, 2014 Share Posted February 3, 2014 duh? I don't what are you huh? Quote Link to comment Share on other sites More sharing options...
Zanarkin Posted February 3, 2014 Share Posted February 3, 2014 D: I'm a dumbfuck thats what Quote Link to comment Share on other sites More sharing options...
Aleph Posted February 3, 2014 Share Posted February 3, 2014 (edited) import sys from sys import * It's actually harder to do it the wrong way than it is to do it the correct way. Or something. Basically, if you're using the re module and you're calling static members of re without prepending them with "re." then you're doing it wrong. Of course a lot of people would say "if you're using the re module you're already doing it wrong" because "if you use regular expressions to solve a problem you now have two problems", but to that I say "you're bad at regular expressions and should be ashamed". Edited February 3, 2014 by Amorphous Laugh Quote Link to comment Share on other sites More sharing options...
Zanarkin Posted February 3, 2014 Share Posted February 3, 2014 thanks ^_^ Quote Link to comment Share on other sites More sharing options...
Aleph Posted February 3, 2014 Share Posted February 3, 2014 I could do what Bal did and try to cite why, or even give a very real example of where it's bit me in the ass to do it the wrong way or put up with other people doing it the wrong way, but...suffice to say, there's a "right way" for a good reason. It's not some elitist crap to pick on people who don't do it the right way. Quote Link to comment Share on other sites More sharing options...
Zanarkin Posted February 3, 2014 Share Posted February 3, 2014 I could do what Bal did and try to cite why, or even give a very real example of where it's bit me in the ass to do it the wrong way or put up with other people doing it the wrong way, but...suffice to say, there's a "right way" for a good reason. It's not some elitist crap to pick on people who don't do it the right way. There is nothing wrong with telling people how to do things the "right way". Particularly when it makes things less cluttered/confusing, more efficient or just readable. Quote Link to comment Share on other sites More sharing options...
Aleph Posted February 3, 2014 Share Posted February 3, 2014 There is a problem with doing stuff just because you're told without at least wondering why, though, and it falls on the person dictating what is to be done to provide that explanation, at least upon request. The best I care to go into at the moment though is just that it will definitely hurt you (probably physically, if your head ache gets bad enough) if you go around using stuff in a module without using full qualification of the entity being utilized. You could end up with a situation where you have to analyze every line using similarly spelled symbols in every source file of your project, which is pretty terrible even for projects with single source files. Quote Link to comment Share on other sites More sharing options...
Esme Posted February 3, 2014 Share Posted February 3, 2014 using std *gigglesnort* Quote Link to comment Share on other sites More sharing options...
euklyd Posted February 3, 2014 Share Posted February 3, 2014 using std *gigglesnort* predictable/10 Quote Link to comment Share on other sites More sharing options...
Esme Posted February 3, 2014 Share Posted February 3, 2014 sh-shut up I'm having fun ;__; Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.