Hi,
I declare some functions in my header file, all of them work but one, which i can't figure out why.
you can see the code here:
the header file:
class myfile
{
public:
myfile(void);
~myfile(void);
int desplay();
void print(int a[],int l);
void print(int a[],int s,int l);
void print(int a);
void print(string s);
};
the cpp file:
#include "stdafx.h"
#include "myfile.h"
#include <string.h>
#include <string>
#include <conio.h>
#include <iostream>
#include <fstream>
using namespace std;
#pragma region constructor_deconstructor
myfile::myfile(void)
{
}
myfile::~myfile(void)
{
}
#pragma endregion constructor_deconstructor
void myfile::print(int a[], int l){
ofstream fp;fp.open("trace.txt",ios::in | ios::app);
if(fp.is_open()){
fp.seekp(ios::ate,ios::end);
fp<<endl;
int i=0;
print("\na[0..");print(l-1);print("] :\n");
for (i=0; i<l; i++){
std::cout<<a[i];
if(i<l-1)cout<<" - ";
fp<<a[i];
if(i<l-1)fp<<" - ";}
}
}
void myfile::print(int a[],int s, int l){
ofstream fp;fp.open("trace.txt",ios::in | ios::app);
if(fp.is_open()){
fp.seekp(ios::ate,ios::end);
fp<<endl;
int i=0;
print("\na[0..");print(l-1);print("] :\n");
for (i=s; i<l; i++){
std::cout<<a[i];
if(i<l-1)cout<<" - ";
fp<<a[i];
if(i<l-1)fp<<" - ";}
}
}
void myfile::print(int a){
ofstream fp;fp.open("trace.txt",ios::in | ios::app);
if(fp.is_open()){
fp.seekp(ios::ate,ios::end);
std::cout<<a;
fp<<a;}
}
void myfile::print(string s){
ofstream fp;fp.open("trace.txt",ios::in | ios::app);
if(fp.is_open()){
fp.seekp(ios::ate,ios::end);
std::cout<<s;
fp<<s;}
}
can you tell me why it gives me the error C2511 about this function which says:
error C2511: 'void myfile::print(int [],int,int)' : overloaded member function not found in 'myfile'
with another error:
intelliSense: no instance of overloaded function "myfile::print" matches the specified type
And i have a redline under the 'print' where i've comented /* here */
why not the rest of them?
and how should i fix it?
Thanks,