Question

So I made this simple program from tutorial, and I get an error that says

Intellisense expected a ';'

The error is on this line int main() line 19

This is the code:

#include "stdafx.h"
#include <Windows.h>
#include <iostream>
#include <string>
using namespace std;

class WilboClass{
public:
        void setName(string x) {
                name = x;
        }
        string getName() {
                return name;
        }
private:
        string name;
}

int main()
{
        WilboClass wo;
        wo.setName("Sir Wilbo Wallace");
        cout << wo.getName();

        Sleep(5000);
        return 0;
}
Was it helpful?

Solution

You just forgot to add semicolon ; after class definition.

class WilboClass{
  public:
    void setName(string x) {
            name = x;
    }
    string getName() {
            return name;
    }
 private:
    string name;
};  // <--  add here

OTHER TIPS

The class definition should be terminated with a ;.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top