Simple.h
#pragma once
class Simple
{
public:
Simple();
void ShowIt();
};
**Simple.cpp**
#include "Simple.h"
#include <iostream>
Simple::Simple()
{
std::cout << "in Simple Constructor" << std::endl;
}
void Simple::ShowIt()
{
std::cout << "Showing It" << std::endl;
}
Main in file CppTutor2023.cpp:
#include "Simple.h"
int main()
{
Simple obj1;
Simple obj2();
obj1.ShowIt();
obj2.ShowIt(); // line 53
...
When I compile this I get the error:
Cpptutor2023.cpp(53,16): error C2228: left of '.ShowIt' must have class/struct/union
I expected line 52 to be the invalid one. Also what is difference between lines 49 & 50? Again, I expected compiler to complain about line 49.
I have Visual Studio options set to use C++ version 17.