Thread: expected ";" before "const" error.

  1. #1
    Registered User
    Join Date
    Jan 2015
    Posts
    30

    expected ";" before "const" error.

    RESOLVED: I looked for about 20 minutes and then immediately after posting this I saw that I had "const" written after constObject.printConst(). Sorry
    main.cpp


    Code:
    #include <iostream>
    #include "class_one.h"
    using namespace std;
    
    
    int main(){
    
    
        class_one firstObject;
        firstObject.print();
    
    
        const class_one constObject;
        constObject.printConst()const;
    }

    class_one.cpp


    Code:
    #include "class_one.h"
    #include <iostream>
    using namespace std;
    
    
    class_one::class_one(){
    }
    
    
    void class_one::print(){
        cout << "This is just a regular function." << endl;
    }
    
    
    void class_one::printConst() const{
        cout << "This is a constant function." << endl;
    }
    class_one.h

    Code:
    #ifndef CLASS_ONE_H
    #define CLASS_ONE_H
    
    
    
    
    class class_one
    {
        public:
            class_one();
            void print();
            void printConst() const;
        protected:
        private:
    };
    
    
    #endif
    Last edited by Aenn; 01-18-2015 at 11:12 AM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 2
    Last Post: 12-08-2014, 08:12 PM
  2. Replies: 9
    Last Post: 03-31-2009, 04:23 PM
  3. Replies: 17
    Last Post: 12-15-2006, 11:02 AM
  4. "itoa"-"_itoa" , "inp"-"_inp", Why some functions have "
    By L.O.K. in forum Windows Programming
    Replies: 5
    Last Post: 12-08-2002, 08:25 AM
  5. "CWnd"-"HWnd","CBitmap"-"HBitmap"...., What is mean by "
    By L.O.K. in forum Windows Programming
    Replies: 2
    Last Post: 12-04-2002, 07:59 AM