I'm making a library for myself, and I keep getting that error :(
Pib.h:

#pragma once
#include "stdafx.h"
#include <iostream>
#include <string>
using namespace std;
class Pib{
public:
	void echo (int Text);
	void test(void);
};
void Pib::echo(int Text){
	printf("Haha: "+Text);
};
void Pib::test(void){
	cout<<"Text";
};

Main File:

#include "stdafx.h"
#include "Pib.h"
#include <iostream>
#include <string>
int main(int argc, _TCHAR* argv[]){
	string a="D:";
	Pib::test();
	getline(cin,a);
	return 0;
}

Thanks if you can help! Keep in mind that I am learning C++ and may need some extra help putting in fixes, :P

I got it to print "Text" to the screen using this code:

#pragma once
#include <iostream>
#include <string>
using namespace std;

class Pib{
public:
	void echo (int Text);
	void test(void);
};
void Pib::echo(int Text){
	printf("Haha: "+Text);
};
void Pib::test(void){
	cout<<"Text";
};
#include "Pib.h"
#include <iostream>
#include <string>

int main(){
    string a="D:";
    Pib pibtest;
    pibtest.test();
    getline(cin,a);
    
    return 0;
}

I was using MS VS 2008 Express Edition.

commented: Thanks alot! +0

When you use a class that you've created you need to make an object of that type in you're main function.

Pib myPib

then test can be called with

myPib.test()

I read online you could call functions like Pib::test();
Know how I could do this? If I have to use this method, I will, i'm just curious. Also - Can I make a inner-object?
ALSO: Thanks for quick replys!

I don't believe you can call class functions without an object. Namespaces use the same :: operator as classes and don't use objects.

namespace Pib
{
   void test();
}

void Pib::test()
{
   cout << "Test" << endl;
}

in main()

Pib::test();

See this link for all about namespaces http://msdn.microsoft.com/en-us/library/014batd5%28VS.80%29.aspx

commented: Thank you ALOT! +0

I did some modifying and made it use namespace. I wanted this because it had intelisense support. Thanks A LOT you two! +Rep!

>>I don't believe you can call class functions without an object.
It can be done.

#include <iostream>
#include <string>

using namespace std;

struct Print
{
	static void print(string str)
	{
		cout << str << endl;
	}
};

int main(){	
	Print::print("string");
}

But from the looks of it, using a namespace would be a better idea.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.