Menu

6 minute errors

David
2007-12-04
2012-09-26
  • David

    David - 2007-12-04

    Dev-C++ 4.9.9.2
    windows xp

    Now i have searched the threads for a while and have found similar problems but no answers that really help so here is my question and hopefully i can get a clearer answer here. I have created a class header and I have run into 6 errors with the header about missing items. Also i got this out of "Sams teach yourself C++" and i have been looking at the example in the book and it matches just about exact i just obmited a few enters and cant seem to find the problem any help would be appreciated

    thanks David

    Compiler: Default compiler
    Executing g++.exe...
    g++.exe "G:\Dev-Cpp\works\classCatBowser.cpp" -o "G:\Dev-Cpp\works\classCatBowser.exe"
    In file included from G:\Dev-Cpp\works\classCatBowser.cpp:1:
    G:/Dev-Cpp/Bin/../lib/gcc/mingw32/3.4.2/../../../../include/c++/3.4.2/backward/cCat.h:9: error: expected unqualified-id before "public"
    G:/Dev-Cpp/Bin/../lib/gcc/mingw32/3.4.2/../../../../include/c++/3.4.2/backward/cCat.h:9: error: expected )' before "public" G:/Dev-Cpp/Bin/../lib/gcc/mingw32/3.4.2/../../../../include/c++/3.4.2/backward/cCat.h:9: error: expected,' or ;' before "public" G:/Dev-Cpp/Bin/../lib/gcc/mingw32/3.4.2/../../../../include/c++/3.4.2/backward/cCat.h:19: error: expected unqualified-id before "private" G:/Dev-Cpp/Bin/../lib/gcc/mingw32/3.4.2/../../../../include/c++/3.4.2/backward/cCat.h:19: error: expected,' or `;' before "private"
    G:/Dev-Cpp/Bin/../lib/gcc/mingw32/3.4.2/../../../../include/c++/3.4.2/backward/cCat.h:22: error: expected declaration before '}' token

    Execution terminated

    Here is the program its-self:

    /Cat class declaration
    Data members are private, public accessor methods
    mediate setting and getting the values of the private data
    /

    include <iostream>

    class cCat
    {
    public:
    //Public accessors
    unsigned int getAge();
    void setAge(unsigned int age);
    unsigned int getWeight();
    void setWeight(unsigned int weight);
    //Public member functions
    void meow();

           //Private member data
    private:
            unsigned int itsAge;
            unsigned int itsWeight;
    

    }

     
    • David

      David - 2007-12-11

      i have all of the config files with it the entire package is on the removable drive so thus it does make it portable if the entire instalation was done directly to that drive

       
    • Anonymous

      Anonymous - 2007-12-04

      You need end the declaration of the class with a semi-colon ";"

      class cCat
      {
      / ... /
      }; // <- here

      HTH

       
    • David

      David - 2007-12-04

      Thanks a bunch i dint even realize that.. first time working with classes so i dint even know about that thanks again.

       
    • David

      David - 2007-12-04

      ok now that i got that problem solved i got a problem with the file that i am using it in and when looking at the compile log for this one i get lost i can see where the problem is occurring but i don't know how to interpret it can some one give me a hint please. I know this one is long but the file is located at the bottom.

      Compiler: Default compiler
      Executing g++.exe...
      g++.exe "G:\Dev-Cpp\works\classCatBowser.cpp" -o "G:\Dev-Cpp\works\classCatBowser.exe"
      G:\Dev-Cpp\works\classCatBowser.cpp: In function `int main()':

      G:\Dev-Cpp\works\classCatBowser.cpp:35: error: no match for 'operator<<' in 'std::operator<< with _Traits = std::char_traits<char>, ((const char)"Bowser is a cat who is ")) << Bowser.cCat::getAge'
      G:/Dev-Cpp/Bin/../lib/gcc/mingw32/3.4.2/../../../../include/c++/3.4.2/bits/ostream.tcc:63: note: candidates are: std::basic_ostream<_CharT, _Traits>& std::basic_ostream<_CharT, _Traits>::operator<<(std::basic_ostream<_CharT, _Traits>&(
      )(std::basic_ostream<_CharT, _Traits>&)) [with _CharT = char, _Traits = std::char_traits<char>]
      G:/Dev-Cpp/Bin/../lib/gcc/mingw32/3.4.2/../../../../include/c++/3.4.2/bits/ostream.tcc:74: note: std::basic_ostream<_CharT, _Traits>& std::basic_ostream<_CharT, _Traits>::operator<<(std::basic_ios<_CharT, _Traits>&()(std::basic_ios<_CharT, _Traits>&)) [with _CharT = char, _Traits = std::char_traits<char>]
      G:/Dev-Cpp/Bin/../lib/gcc/mingw32/3.4.2/../../../../include/c++/3.4.2/bits/ostream.tcc:86: note: std::basic_ostream<_CharT, _Traits>& std::basic_ostream<_CharT, _Traits>::operator<<(std::ios_base&(
      )(std::ios_base&)) [with _CharT = char, _Traits = std::char_traits<char>]
      G:/Dev-Cpp/Bin/../lib/gcc/mingw32/3.4.2/../../../../include/c++/3.4.2/bits/ostream.tcc:121: note: std::basic_ostream<_CharT, _Traits>& std::basic_ostream<_CharT, _Traits>::operator<<(long int) [with _CharT = char, _Traits = std::char_traits<char>]
      G:/Dev-Cpp/Bin/../lib/gcc/mingw32/3.4.2/../../../../include/c++/3.4.2/bits/ostream.tcc:155: note: std::basic_ostream<_CharT, _Traits>& std::basic_ostream<_CharT, _Traits>::operator<<(long unsigned int) [with _CharT = char, _Traits = std::char_traits<char>]
      G:/Dev-Cpp/Bin/../lib/gcc/mingw32/3.4.2/../../../../include/c++/3.4.2/bits/ostream.tcc:98: note: std::basic_ostream<_CharT, _Traits>& std::basic_ostream<_CharT, _Traits>::operator<<(bool) [with _CharT = char, _Traits = std::char_traits<char>]
      G:/Dev-Cpp/Bin/../lib/gcc/mingw32/3.4.2/../../../../include/c++/3.4.2/ostream:178: note: std::basic_ostream<_CharT, _Traits>& std::basic_ostream<_CharT, _Traits>::operator<<(short int) [with _CharT = char, _Traits = std::char_traits<char>]
      G:/Dev-Cpp/Bin/../lib/gcc/mingw32/3.4.2/../../../../include/c++/3.4.2/ostream:189: note: std::basic_ostream<_CharT, _Traits>& std::basic_ostream<_CharT, _Traits>::operator<<(short unsigned int) [with _CharT = char, _Traits = std::char_traits<char>]
      G:/Dev-Cpp/Bin/../lib/gcc/mingw32/3.4.2/../../../../include/c++/3.4.2/ostream:193: note: std::basic_ostream<_CharT, _Traits>& std::basic_ostream<_CharT, _Traits>::operator<<(int) [with _CharT = char, _Traits = std::char_traits<char>]
      G:/Dev-Cpp/Bin/../lib/gcc/mingw32/3.4.2/../../../../include/c++/3.4.2/ostream:204: note: std::basic_ostream<_CharT, _Traits>& std::basic_ostream<_CharT, _Traits>::operator<<(unsigned int) [with _CharT = char, _Traits = std::char_traits<char>]
      G:/Dev-Cpp/Bin/../lib/gcc/mingw32/3.4.2/../../../../include/c++/3.4.2/bits/ostream.tcc:179: note: std::basic_ostream<_CharT, _Traits>& std::basic_ostream<_CharT, _Traits>::operator<<(long long int) [with _CharT = char, _Traits = std::char_traits<char>]
      G:/Dev-Cpp/Bin/../lib/gcc/mingw32/3.4.2/../../../../include/c++/3.4.2/bits/ostream.tcc:214: note: std::basic_ostream<_CharT, _Traits>& std::basic_ostream<_CharT, _Traits>::operator<<(long long unsigned int) [with _CharT = char, _Traits = std::char_traits<char>]
      G:/Dev-Cpp/Bin/../lib/gcc/mingw32/3.4.2/../../../../include/c++/3.4.2/bits/ostream.tcc:238: note: std::basic_ostream<_CharT, _Traits>& std::basic_ostream<_CharT, _Traits>::operator<<(double) [with _CharT = char, _Traits = std::char_traits<char>]
      G:/Dev-Cpp/Bin/../lib/gcc/mingw32/3.4.2/../../../../include/c++/3.4.2/ostream:219: note: std::basic_ostream<_CharT, _Traits>& std::basic_ostream<_CharT, _Traits>::operator<<(float) [with _CharT = char, _Traits = std::char_traits<char>]

      G:/Dev-Cpp/Bin/../lib/gcc/mingw32/3.4.2/../../../../include/c++/3.4.2/bits/ostream.tcc:261: note: std::basic_ostream<_CharT, _Traits>& std::basic_ostream<_CharT, _Traits>::operator<<(long double) [with _CharT = char, _Traits = std::char_traits<char>]
      G:/Dev-Cpp/Bin/../lib/gcc/mingw32/3.4.2/../../../../include/c++/3.4.2/bits/ostream.tcc:284: note: std::basic_ostream<_CharT, _Traits>& std::basic_ostream<_CharT, _Traits>::operator<<(const void) [with _CharT = char, _Traits = std::char_traits<char>]
      G:/Dev-Cpp/Bin/../lib/gcc/mingw32/3.4.2/../../../../include/c++/3.4.2/bits/ostream.tcc:307: note: std::basic_ostream<_CharT, _Traits>& std::basic_ostream<_CharT, _Traits>::operator<<(std::basic_streambuf<_CharT, _Traits>
      ) [with _CharT = char, _Traits = std::char_traits<char>]
      G:/Dev-Cpp/Bin/../lib/gcc/mingw32/3.4.2/../../../../include/c++/3.4.2/ostream:504: note: std::basic_ostream<char, _Traits>& std::operator<<(std::basic_ostream<char, _Traits>&, const unsigned char) [with _Traits = std::char_traits<char>]
      G:/Dev-Cpp/Bin/../lib/gcc/mingw32/3.4.2/../../../../include/c++/3.4.2/ostream:499: note: std::basic_ostream<char, _Traits>& std::operator<<(std::basic_ostream<char, _Traits>&, const signed char
      ) [with _Traits = std::char_traits<char>]
      G:/Dev-Cpp/Bin/../lib/gcc/mingw32/3.4.2/../../../../include/c++/3.4.2/bits/ostream.tcc:612: note: std::basic_ostream<char, _Traits>& std::operator<<(std::basic_ostream<char, _Traits>&, const char) [with _Traits = std::char_traits<char>]
      G:/Dev-Cpp/Bin/../lib/gcc/mingw32/3.4.2/../../../../include/c++/3.4.2/bits/ostream.tcc:567: note: std::basic_ostream<_CharT, _Traits>& std::operator<<(std::basic_ostream<_CharT, _Traits>&, const char
      ) [with _CharT = char, _Traits = std::char_traits<char>]
      G:/Dev-Cpp/Bin/../lib/gcc/mingw32/3.4.2/../../../../include/c++/3.4.2/ostream:465: note: std::basic_ostream<char, _Traits>& std::operator<<(std::basic_ostream<char, _Traits>&, unsigned char) [with _Traits = std::char_traits<char>]
      G:/Dev-Cpp/Bin/../lib/gcc/mingw32/3.4.2/../../../../include/c++/3.4.2/ostream:460: note: std::basic_ostream<char, _Traits>& std::operator<<(std::basic_ostream<char, _Traits>&, signed char) [with _Traits = std::char_traits<char>]
      G:/Dev-Cpp/Bin/../lib/gcc/mingw32/3.4.2/../../../../include/c++/3.4.2/bits/ostream.tcc:505: note: std::basic_ostream<char, _Traits>& std::operator<<(std::basic_ostream<char, _Traits>&, char) [with _Traits = std::char_traits<char>]
      G:/Dev-Cpp/Bin/../lib/gcc/mingw32/3.4.2/../../../../include/c++/3.4.2/ostream:449: note: std::basic_ostream<_CharT, _Traits>& std::operator<<(std::basic_ostream<_CharT, _Traits>&, char) [with _CharT = char, _Traits = std::char_traits<char>]
      G:\Dev-Cpp\works\classCatBowser.cpp:36: error: no match for 'operator<<' in 'std::operator<< with _Traits = std::char_traits<char>, ((const char)"and he weighs ")) << Bowser.cCat::getWeight'
      G:/Dev-Cpp/Bin/../lib/gcc/mingw32/3.4.2/../../../../include/c++/3.4.2/bits/ostream.tcc:63: note: candidates are: std::basic_ostream<_CharT, _Traits>& std::basic_ostream<_CharT, _Traits>::operator<<(std::basic_ostream<_CharT, _Traits>&(
      )(std::basic_ostream<_CharT, _Traits>&)) [with _CharT = char, _Traits = std::char_traits<char>]
      G:/Dev-Cpp/Bin/../lib/gcc/mingw32/3.4.2/../../../../include/c++/3.4.2/bits/ostream.tcc:74: note: std::basic_ostream<_CharT, _Traits>& std::basic_ostream<_CharT, _Traits>::operator<<(std::basic_ios<_CharT, _Traits>&()(std::basic_ios<_CharT, _Traits>&)) [with _CharT = char, _Traits = std::char_traits<char>]
      G:/Dev-Cpp/Bin/../lib/gcc/mingw32/3.4.2/../../../../include/c++/3.4.2/bits/ostream.tcc:86: note: std::basic_ostream<_CharT, _Traits>& std::basic_ostream<_CharT, _Traits>::operator<<(std::ios_base&(
      )(std::ios_base&)) [with _CharT = char, _Traits = std::char_traits<char>]
      G:/Dev-Cpp/Bin/../lib/gcc/mingw32/3.4.2/../../../../include/c++/3.4.2/bits/ostream.tcc:121: note: std::basic_ostream<_CharT, _Traits>& std::basic_ostream<_CharT, _Traits>::operator<<(long int) [with _CharT = char, _Traits = std::char_traits<char>]

      G:/Dev-Cpp/Bin/../lib/gcc/mingw32/3.4.2/../../../../include/c++/3.4.2/bits/ostream.tcc:155: note: std::basic_ostream<_CharT, _Traits>& std::basic_ostream<_CharT, _Traits>::operator<<(long unsigned int) [with _CharT = char, _Traits = std::char_traits<char>]
      G:/Dev-Cpp/Bin/../lib/gcc/mingw32/3.4.2/../../../../include/c++/3.4.2/bits/ostream.tcc:98: note: std::basic_ostream<_CharT, _Traits>& std::basic_ostream<_CharT, _Traits>::operator<<(bool) [with _CharT = char, _Traits = std::char_traits<char>]
      G:/Dev-Cpp/Bin/../lib/gcc/mingw32/3.4.2/../../../../include/c++/3.4.2/ostream:178: note: std::basic_ostream<_CharT, _Traits>& std::basic_ostream<_CharT, _Traits>::operator<<(short int) [with _CharT = char, _Traits = std::char_traits<char>]
      G:/Dev-Cpp/Bin/../lib/gcc/mingw32/3.4.2/../../../../include/c++/3.4.2/ostream:189: note: std::basic_ostream<_CharT, _Traits>& std::basic_ostream<_CharT, _Traits>::operator<<(short unsigned int) [with _CharT = char, _Traits = std::char_traits<char>]
      G:/Dev-Cpp/Bin/../lib/gcc/mingw32/3.4.2/../../../../include/c++/3.4.2/ostream:193: note: std::basic_ostream<_CharT, _Traits>& std::basic_ostream<_CharT, _Traits>::operator<<(int) [with _CharT = char, _Traits = std::char_traits<char>]
      G:/Dev-Cpp/Bin/../lib/gcc/mingw32/3.4.2/../../../../include/c++/3.4.2/ostream:204: note: std::basic_ostream<_CharT, _Traits>& std::basic_ostream<_CharT, _Traits>::operator<<(unsigned int) [with _CharT = char, _Traits = std::char_traits<char>]

      G:/Dev-Cpp/Bin/../lib/gcc/mingw32/3.4.2/../../../../include/c++/3.4.2/bits/ostream.tcc:179: note: std::basic_ostream<_CharT, _Traits>& std::basic_ostream<_CharT, _Traits>::operator<<(long long int) [with _CharT = char, _Traits = std::char_traits<char>]
      G:/Dev-Cpp/Bin/../lib/gcc/mingw32/3.4.2/../../../../include/c++/3.4.2/bits/ostream.tcc:214: note: std::basic_ostream<_CharT, _Traits>& std::basic_ostream<_CharT, _Traits>::operator<<(long long unsigned int) [with _CharT = char, _Traits = std::char_traits<char>]
      G:/Dev-Cpp/Bin/../lib/gcc/mingw32/3.4.2/../../../../include/c++/3.4.2/bits/ostream.tcc:238: note: std::basic_ostream<_CharT, _Traits>& std::basic_ostream<_CharT, _Traits>::operator<<(double) [with _CharT = char, _Traits = std::char_traits<char>]
      G:/Dev-Cpp/Bin/../lib/gcc/mingw32/3.4.2/../../../../include/c++/3.4.2/ostream:219: note: std::basic_ostream<_CharT, _Traits>& std::basic_ostream<_CharT, _Traits>::operator<<(float) [with _CharT = char, _Traits = std::char_traits<char>]
      G:/Dev-Cpp/Bin/../lib/gcc/mingw32/3.4.2/../../../../include/c++/3.4.2/bits/ostream.tcc:261: note: std::basic_ostream<_CharT, _Traits>& std::basic_ostream<_CharT, _Traits>::operator<<(long double) [with _CharT = char, _Traits = std::char_traits<char>]
      G:/Dev-Cpp/Bin/../lib/gcc/mingw32/3.4.2/../../../../include/c++/3.4.2/bits/ostream.tcc:284: note: std::basic_ostream<_CharT, _Traits>& std::basic_ostream<_CharT, _Traits>::operator<<(const void) [with _CharT = char, _Traits = std::char_traits<char>]
      G:/Dev-Cpp/Bin/../lib/gcc/mingw32/3.4.2/../../../../include/c++/3.4.2/bits/ostream.tcc:307: note: std::basic_ostream<_CharT, _Traits>& std::basic_ostream<_CharT, _Traits>::operator<<(std::basic_streambuf<_CharT, _Traits>
      ) [with _CharT = char, _Traits = std::char_traits<char>]
      G:/Dev-Cpp/Bin/../lib/gcc/mingw32/3.4.2/../../../../include/c++/3.4.2/ostream:504: note: std::basic_ostream<char, _Traits>& std::operator<<(std::basic_ostream<char, _Traits>&, const unsigned char) [with _Traits = std::char_traits<char>]
      G:/Dev-Cpp/Bin/../lib/gcc/mingw32/3.4.2/../../../../include/c++/3.4.2/ostream:499: note: std::basic_ostream<char, _Traits>& std::operator<<(std::basic_ostream<char, _Traits>&, const signed char
      ) [with _Traits = std::char_traits<char>]
      G:/Dev-Cpp/Bin/../lib/gcc/mingw32/3.4.2/../../../../include/c++/3.4.2/bits/ostream.tcc:612: note: std::basic_ostream<char, _Traits>& std::operator<<(std::basic_ostream<char, _Traits>&, const char) [with _Traits = std::char_traits<char>]
      G:/Dev-Cpp/Bin/../lib/gcc/mingw32/3.4.2/../../../../include/c++/3.4.2/bits/ostream.tcc:567: note: std::basic_ostream<_CharT, _Traits>& std::operator<<(std::basic_ostream<_CharT, _Traits>&, const char
      ) [with _CharT = char, _Traits = std::char_traits<char>]
      G:/Dev-Cpp/Bin/../lib/gcc/mingw32/3.4.2/../../../../include/c++/3.4.2/ostream:465: note: std::basic_ostream<char, _Traits>& std::operator<<(std::basic_ostream<char, _Traits>&, unsigned char) [with _Traits = std::char_traits<char>]
      G:/Dev-Cpp/Bin/../lib/gcc/mingw32/3.4.2/../../../../include/c++/3.4.2/ostream:460: note: std::basic_ostream<char, _Traits>& std::operator<<(std::basic_ostream<char, _Traits>&, signed char) [with _Traits = std::char_traits<char>]
      G:/Dev-Cpp/Bin/../lib/gcc/mingw32/3.4.2/../../../../include/c++/3.4.2/bits/ostream.tcc:505: note: std::basic_ostream<char, _Traits>& std::operator<<(std::basic_ostream<char, _Traits>&, char) [with _Traits = std::char_traits<char>]
      G:/Dev-Cpp/Bin/../lib/gcc/mingw32/3.4.2/../../../../include/c++/3.4.2/ostream:449: note: std::basic_ostream<_CharT, _Traits>& std::operator<<(std::basic_ostream<_CharT, _Traits>&, char) [with _CharT = char, _Traits = std::char_traits<char>]

      Execution terminated

      Here is the file

      include <cCat.h>

      unsigned int cCat::getAge()
      {
      return itsAge;
      }

      void cCat::setAge(unsigned int age)
      {
      itsAge = age;
      }

      unsigned int cCat::getWeight()
      {
      return itsWeight;
      }

      void cCat::setWeight(unsigned int weight)
      {
      itsWeight = weight;
      }

      void cCat::meow()
      {
      std::cout << "Meow.\n";
      }

      int main()
      {
      cCat Bowser;
      Bowser.setAge(3);
      Bowser.setWeight(5);
      Bowser.meow();
      std::cout << "Bowser is a cat who is " << Bowser.getAge << " years old, ";
      std::cout << "and he weighs " << Bowser.getWeight << " pounds.";
      Bowser.meow();

      system(&quot;pause&quot;);
      return 0;
      

      }

       
    • BiT

      BiT - 2007-12-04

      int main()
      {
      cCat Bowser;
      Bowser.setAge(3); <---- look at how you call this function.
      Bowser.setWeight(5);
      Bowser.meow();
      std::cout << "Bowser is a cat who is " << Bowser.getAge << " years old, "; <---- look at this What is missing?
      std::cout << "and he weighs " << Bowser.getWeight << " pounds."; <--- missing here too
      Bowser.meow();

      system("pause");
      return 0;
      }

       
    • David

      David - 2007-12-04

      Again thanks for the help guys and BiT thanks thats the little push that I needed. But the whole complier log thing is Greek to me i don't even know where to brake it down. I mean i can see where it says the line that it occurs on but when it gets to the technical information I might as well try reading Russian or something that I have no idea about. So could you tell me what some of it means or is it in the Read this first forum and i just passed over it?

       
    • BiT

      BiT - 2007-12-04

      the first 2 lines(at least how it is displayed here) tell you what the error was

      G:\Dev-Cpp\works\classCatBowser.cpp:35: error: no match for 'operator<<' in 'std::operator<< with _Traits = std::char_traits<char>, ((const char*)"Bowser is a cat who is ")) << Bowser.cCat::getAge' <--- telling you this is the problem

      everything else after that is a result of that error.

       
    • David

      David - 2007-12-04

      so let me see if i got this the main gut of the line that you pulled out is the line "G:\Dev-Cpp\works\classCatBowser.cpp:35: error:" which is 35 and the end "Bowser.cCat::getAge" which tells which variable has a problem, or do i have to wait with trial and error before i finally comprehend the compile log like learning math or another language(even though this is a language in and of itself...)

       
    • Anonymous

      Anonymous - 2007-12-04

      Pardon me for pointing out the elephant in teh room, but waht is your header file doing in "/../../../../include/c++/3.4.2/backward/" !?

      Don't put your project header files in the system header folders - that way lies madness! Put it with your project. If you wish to separate headers and sources, create a private folder and ass a -I<path> switch to the project options.

      More forgiveable but still problematic is putting the project itself in a subfolder of the Dev-Cpp installation folder. For some bizarre reason on occasions (and by no means on every occasion) Dev-C++ builds fail is strange ways when you do that. Apart from that it is just a bad ideal all-round to 'pollute' the tool installation with your own files - imagine what will happen if you have to reinstall or upgrade or build your project on a different machine.

      Clifford

       
      • Anonymous

        Anonymous - 2007-12-04

        Now I swear I corrected ass->add, but I guess the evidence is against me. And as for the other typo's - well, it's later here ;-)

         
    • David

      David - 2007-12-04

      Lol well I understood what your where saying and I get where you are coming from so I just moved a few things around so now they are out of the parent folder. but i would never have to try to build my project on another machine because I installed the program on my removable hard drive for that vary purpose(unless, like usual, I am wrong of course).

       
      • cpns

        cpns - 2007-12-11

        Installing Dev-C++ on a removable drive does not by itself make it portable. See: http://sourceforge.net/projects/devcpp-portable

        Clifford

         

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.