Can u to acess function of this class??

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#include<iostream>
#include<conio.h>
#include<string>
using namespace std;

class RoughStrings {
public:
int minRoughness(string, int);
   };

                       int RoughStrings::minRoughness(string s, int n) {
                          s=("i m inside function") ;
                           cout<<s<<endl;     
                         return 0;}

int main(){
     RoughStrings obj;
     
     obj.minRoughness(); // error at this point => 
         
      /*      No matching function for call        RoughStrings::minRoughness()'                                                                                                      `              */
     
       cout<<"i m in main"<<endl;
    
     
     getch();
    return 0;
    }
Last edited on
You get the error, because you didn't provide the required arguments for minRoughness. You must pass a string for "a" and an integer for "n". e.g. obj.minRoughtness("foo", -1);
Of course you can
change the line this this:
 
int RoughStrings::minRoughness(string s = "", int n = 0) {
Topic archived. No new replies allowed.