The following works fine:
Header file:
Code:
#ifndef stringproj_h
#define stringproj_h
void show(int s);
#endif
Implementation file:
Code:
#include<iostream>
#include "stringproj.h"
using namespace std;
void show (int s){
cout<<s<<endl;
}
Client file
Code:
#include <iostream>
#include"stringproj.h"
using namespace std;
int main(){
show(7);
}
But when I try to extend the same framework to strings ...:
Header file:
Code:
#ifndef stringproj_h
#define stringproj_h
#include<iostream>
#include<string>
void show(string s);
#endif
Implementation file
Code:
#include<iostream>
#include<string>
#include "stringproj.h"
using namespace std;
void show (string s){
cout<<s<<endl;
}
Client file
Code:
#include <iostream>
#include"stringproj.h"
#include<string>
using namespace std;
int main(){
show("Hello World");
}
... get 2 error messages relating to implementation file:
1. variable or field 'show' declared void;
2. 'string' was not declared in this scope;
and 1 error message relating to client file:
1.'show' was not declared in this scope
Suggestions on how to make strings work and any other observations would be much appreciated. Thanks