Search code examples
c++

Define an empty constructor in c++


In main.cpp

LLC* llc = new LLC();

Here is the constructor in llc.cpp

LLC::LLC() :
{
    cout<<"test"<<endl;
}

Here is the error that I get:

llc.cpp(36): error: expected an identifier
{
^

What mistake am I making? The constructor is given in the public section of the class LLC in the header file of llc.cpp


Solution

  • LLC::LLC() :
    {
        cout<<"test"<<endl;
    }
    

    should be

    LLC::LLC()
    {
        cout<<"test"<<endl;
    }