Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
‘int R::print() const’ cannot be overloaded
#include<iostream> using namespace std; class R { public: R(int r1, int r2) : r1(r1), r2(r2) { } void print(); void print() const; // Tried to test overload "void print() const" member function must be Void type?? int print() const; //error private: int r1, r2; }; void R::print() { cout << r1 << "," << r2 << endl; } void R::print() const { cout<<"Const" << r1 << "," << r2 << endl; } int R::print1() const { cout<<"Int Const" << this->r1 << "," << this->r2 << endl; return 1; } int main() { R a(5,4); a.print(); //calling void print() const R b(20,52); b.print(); //calling void print() const R c(12,16); c.print(); //calling int print() const return 0; }
run
|
edit
|
history
|
help
0
Pierwiastkowanie
char strcpy
StrSubCpyFind
constructing object on first use as return value of (pointer to) object-returning function
Stream4
Kalkulator z bajerami
Perfect Square Solution
member initial list
good triplet
шаблонизированное наследование