Compilers

This is a discussion on Compilers within the C++ Programming forums, part of the General Programming Boards category; Ok well until I got this strange error on my Codeblocks IDE I switched to Visual Studio and all these ...

  1. #1
    Registered User
    Join Date
    Jun 2009
    Location
    Adeliade, AU
    Posts
    128

    Compilers

    Ok well until I got this strange error on my Codeblocks IDE I switched to Visual Studio and all these errors are popping up which I never had before. Are there settings I can change or is it that VS is more standard practice?

    E.g . This code was fine and working beforehand but now in VS it says that..

    1>p:\koa_dm_it\koa_dm_it\main.cpp(47) : error C3861: 'transform': identifier not found

    Code:
        do {                                                                                                                  // Do While -
            getline(cin,sTempChosenPet);                                                                                      // Input
            transform(sTempChosenPet.begin(), sTempChosenPet.end(), sTempChosenPet.begin(), ::tolower);                       // transform function, uppercase to lower

  2. #2
    Registered User
    Join Date
    Jun 2005
    Posts
    6,618
    You probably need to add an #include <algorithm> to the source file above the offending line.

    Without that header explicitly included, algorithms like transform are not guaranteed to work. However, it will work with some compilers and libraries, if some of the standard header files associated with that implementation happen to #include other standard header files.

  3. #3
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Posts
    22,985
    1) Did you include <algorithm>?
    2) Did you add using namespace std;?
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  4. #4
    Registered User
    Join Date
    Jun 2009
    Location
    Adeliade, AU
    Posts
    128
    I think grumpy is right.

    I did include namespace but not algorithm.

    How exactly does VS compile? I just fixed that error but now my pet class is not working which worked before >.<


    main.cpp
    Code:
    //Pet Definitions----->
        Cat Espeon;
        Dog Ruffles;
        Eagle Eskia;
    //--------------------<

    pets.h
    Code:
    #include "classes.h"
    
    Cat::Cat() {}
    Cat::~Cat() {}
    //
    Dog::Dog() {}
    Dog::~Dog() {}
    //
    Eagle::Eagle() {}
    Eagle::~Eagle() {}
    classes.h
    Code:
    // Player Pet Classes START //
    //--------------------------//
    
    class Cat                                                          // Begins declaration of class
    {                                                                  //
        public:                                                        // Begins public section                                                   //
            void Meow() {cout << "Meow! \n\n";}                        // General functions and so fourth
            void Info() {;}
        private:
    };
    
    class Dog                                                          // Begins declaration of class
    {                                                                  //
        public:                                                        // Begins public section                                                  //
            void Woof() {cout << "Woof! \n\n";}                        // General functions and so fourth
            void Info()    {;}
        private:
    };
    
    class Eagle                                                        // Begins declaration of class
    {                                                                  //
        public:                                                        // Begins public section                                                  //
            void Screech() {cout << "Sssscccrrreeacchh! \n\n";}        // General functions and so fourth
            void Info()    {;}
        private:
    };
    
    //--------------------------------------<<
    This is what I had before in Codeblocks and it compiled and worked fine. Now in VS I get

    1>p:\koa_dm_it\koa_dm_it\pets.cpp(7) : error C2600: 'Dog:og' : cannot define a compiler-generated special member function (must be declared in the class first)
    1>p:\koa_dm_it\koa_dm_it\pets.cpp(8) : error C2600: 'Dog::~Dog' : cannot define a compiler-generated special member function (must be declared in the class first)
    1>p:\koa_dm_it\koa_dm_it\pets.cpp(10) : error C2600: 'Eagle::Eagle' : cannot define a compiler-generated special member function (must be declared in the class first)
    1>p:\koa_dm_it\koa_dm_it\pets.cpp(11) : error C2600: 'Eagle::~Eagle' : cannot define a compiler-generated special member function (must be declared in the class first)

    Maybe I should stick to my old compiler? Or is it letting me do bad things

  5. #5
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Posts
    22,985
    Your old compiler is letting you do bad things.
    The reason you get these errors is because you have never declared those constructors and destructors in the class declarations (as the error message happily tells you).
    Last edited by Elysia; 07-14-2009 at 05:58 AM.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  6. #6
    Registered User
    Join Date
    Jun 2009
    Location
    Adeliade, AU
    Posts
    128
    Yeah as I suspected. Think Ill scrap the old compiler its causing me some set backs

  7. #7
    Registered User
    Join Date
    Jun 2005
    Posts
    6,618
    Quote Originally Posted by Elysia View Post
    The reason you get these errors is because you have never defined those constructors and destructors in the class declarations (as the error message happily tells you).
    Correct, except that the word "defined" (which I've underlined) should be "declared". The error messages result from trying to define class constructors that have not been declared.

    Quote Originally Posted by Aliaks View Post
    Yeah as I suspected. Think Ill scrap the old compiler its causing me some set backs
    What old compiler are you using? And, probably more important, what standard library?

    Code::Blocks is an IDE which can be configured to support a number of compilers. By default, it uses gcc. I've used versions of gcc that predate Code::Blocks by well over a decade, and never seen it accept code like yours without complaint. So, unless you're using Code::Blocks in some unusual configuration, you shouldn't expect to see your code compile successfully.
    Last edited by grumpy; 07-14-2009 at 05:52 AM.
    Right 98% of the time, and don't care about the other 3%.

    If I seem grumpy or unhelpful in reply to you, or tell you you need to demonstrate more effort before you can expect help, it is likely you deserve it. Suck it up, Sunshine, and read this, this, and this before posting again.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. C++ Builder Comparison
    By ryanlcs in forum Tech Board
    Replies: 14
    Last Post: 08-20-2006, 10:56 AM
  2. True c compilers
    By the_old_nyx in forum C Programming
    Replies: 9
    Last Post: 07-24-2006, 07:09 PM
  3. Is It Possible To Install Multiple Compilers?
    By mishna_toreh in forum C Programming
    Replies: 3
    Last Post: 05-13-2005, 08:32 AM
  4. Compilers for Windows
    By LegendsEnd in forum Windows Programming
    Replies: 2
    Last Post: 03-26-2004, 08:03 AM
  5. Compilers, Compilers, Compilers
    By Stan100 in forum C++ Programming
    Replies: 11
    Last Post: 11-08-2002, 04:21 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21