Hej,
Sitter i skolan och skall göra en enkel uppgift men jag får inte till kompileringen. Har gjort massa liknande uppgifter förut men nu fungerar det helt plötsligt inte.
replace.h:
#ifndef ____replace__
#define ____replace__
#include <iostream>
namespace cpp_lab3 {
class Replace {
public:
void replace_all(string& s, const string& from, const string& to);
};
}
#endif
replace.cc:
#include "replace.h"
#include <string>
using namespace std;
namespace cpp_lab3 {
void Replace::replace_all(string& s, string& from, string& to) {
}
}
replacetest.cc:
#include <stdio.h>
#include "replace.h"
#include <string>
using namespace std;
using namespace cpp_lab3;
int main() {
string text = "A man, a plan, a canal, Panama!";
replace_all(text, "an", "XXX");
assert(text == "A mXXX, a plXXX, a cXXXal, PXXXama!");
text = "ananan";
replace_all(text, "an", "XXX");
assert(text == "XXXXXXXXX");
text = "ananan";
replace_all(text, "an", "anan");
assert(text == "anananananan");
}
När jag kompilerar får jag följande fel:
g++ -c replace.cc
replace.cc:8: error: prototype for ‘void cpp_lab3::Replace::replace_all(std::string&, std::string&, std::string&)’ does not match any in class ‘cpp_lab3::Replace’
replace.h:11: error: candidate is: void cpp_lab3::Replace::replace_all(int&, int)
Några idéer?
Tack!