Hello I'm just starting to comprehend using classes in C++. Can't seem to get this simple program to work.
I get the error:
main.obj : error LNK2019: unresolved external symbol "public: int __thiscall functions::add(int,int)" (?add@functions@@QAEHHH@Z) referenced in function _wmain
1>c:\users\brr\documents\visual studio 2012\Projects\ConsoleApplication4\Debug\ConsoleApplication4.exe : fatal error LNK1120: 1 unresolved externals
My code is as follows:
main.cpp:
// ConsoleApplication4.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include "functions.h"
#include <iostream>
int _tmain(int argc, _TCHAR* argv[])
{
bool running = true;
while(running)
{
functions func;
int var1, var2;
int option = 0;
switch (option)
{
case(1):
std::cin >> var1 >> var2;
func.add(var1,var2);
}
}
return 0;
}
functions.cpp:
#include "functions.h"
#include <iostream>
functions::functions(void)
{
}
functions::~functions(void)
{
}
int add(int var1,int var2){
int r;
r = var1 + var2;
return r;
}
functions.h:
#pragma once
class functions
{
public:
functions(void);
~functions(void);
int add(int var1,int var2);
};