0

I created this but i am getting linking errors but i don't know why...

SysInfo.h

#include <iostream>

class SysInfo 
{

  public:
    SysInfo();
    ~SysInfo();

  private:

};

SysInfo.cpp

#include "SysInfo.h"

using namespace std;

SysInfo::SysInfo()
{
  cout << "Object is being created" << endl;
} 

SysInfo::~SysInfo()
{
  cout << "Object is being deleted" << endl;
}

Main

#include <tchar.h>
#include "Sysinfo.h" 

using namespace std;

int _tmain(int argc, _TCHAR* argv[])
{
    SysInfo inf;
    getchar();

    return 0;
}

Message

warning C4930: 'SysInfo inf(void)': prototyped function not called (was a variable definition intended?)

The issue is solved. The code you see is corrected code. I changed #include <SysInfo.h> to #include "SysInfo.h" and turned off the pre compile setting in visual studio 2012. That was giving errors ass well.

3 Answers3

2

SysInfo inf(); is a declaration of function inf, returning SysInfo class.

Should be SysInfo inf;

#include <SysInfo.h> is a possible source of concern too. See this for the additional info.

Community
  • 1
  • 1
Ari0nhh
  • 5,720
  • 3
  • 28
  • 33
1

SysInfo inf(); is a function declaration! A method named inf that takes nothing and returns SysInfo.

Do this to declare object of SysInfo: SysInfo inf;

CinCout
  • 9,486
  • 12
  • 49
  • 67
0

Because your constructor have not any parameters, so you should replace :

int main()
{
    SysInfo inf;
}

with bellow :

int main()
{
    SysInfo inf();
}

so try with SysInfo inf without ().