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.

Comments
Thanks alot!

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 did some modifying and made it use namespace. I wanted this because it had intelisense support. Thanks A LOT you two! +Rep!

Edited 6 Years Ago by Someguynamedpie: n/a

>>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.

This question has already been answered. Start a new discussion instead.