Jump to content

  • Log In with Google      Sign In   
  • Create Account

Awesome job so far everyone! Please give us your feedback on how our article efforts are going. We still need more finished articles for our May contest theme: Remake the Classics

#Actualrip-off

Posted 25 July 2012 - 07:01 AM

It is a static variable, so it must be defined outside of any function. The lines I quoted would go, for example, here:
#include <iostream>
#include <string>
#include "console.h"

using namespace std;

string Console::prefix = "[Log]";

void Console::setPrefix(string msg) {
    prefix = msg;
}

void Console::log(string msg) {
    std::cout << prefix << " " << msg;
}

#2rip-off

Posted 25 July 2012 - 07:00 AM

It is a static variable, so it must be defined outside of any function. The lines I quoted would go, for example, here:
#include <iostream>
#include <string>
#include "console.h"

using namespace std;

string Console::prefix = "[Log]";

void Console::setPrefix(string msg) {
		prefix = msg;
}

void Console::log(string msg) {
		std::cout << prefix << " " << msg;
}

#1rip-off

Posted 25 July 2012 - 07:00 AM

It is a static variable, so it must be defined outside of any function. The lines I quoted would go, for example, here:
#include <iostream>
#include <string>
#include "console.h"

using namespace std;


string Console::prefix = "[Log]";

void Console::setPrefix(string msg) {
	    prefix = msg;
}

void Console::log(string msg) {
	    std::cout << prefix << " " << msg;
}

PARTNERS