Saturday, April 19, 2025

C++ OO Conflicting Objects


#include <iostream>

using namespace std;

class Cls1{
    public:
        void sameName() {
            cout << "I am from Cls 1" << endl;
        }
};

class Cls2{
    public:
        void sameName() {
            cout << "I am from Cls 2" << endl;
        }
};

int main() {

    Cls1 Object;
    Object.sameName();

    Cls2 Object;
    Object.sameName();

    return 0;
}

||=== Build: Debug in Main (compiler: GNU GCC Compiler) ===|
C:\Users\user\Desktop\Main\main.cpp||In function 'int main()':|
C:\Users\user\Desktop\Main\main.cpp|24|error: conflicting declaration 'Cls2 Object'|
C:\Users\user\Desktop\Main\main.cpp|21|note: previous declaration as 'Cls1 Object'|
||=== Build failed: 1 error(s), 0 warning(s) (0 minute(s), 0 second(s)) ===|

No comments:

Post a Comment

Tkinter Introduction - Top Widget, Method, Button

First, let's make shure that our tkinter module is working ok with simple  for loop that will spawn 5 instances of blank Tk window .  ...