Answer the question
In order to leave comments, you need to log in
Why is V::set() not a member of "V"? Where is the mistake?
I can't find the error, can you tell me where?
// Выполнил Вариант №21
#include<conio.h>
#include<stdio.h>
#include<stdlib.h>
#include<iostream.h>
class V {
float y;
public:
V();
V(const V &);
V(float yn) {
y = yn;
}
float inc() {
return++y;
}
friend void inc(V&);
friend int cmpL(V, V);
void set(int);
V div(V, V);
};
V::V(const V &p) {
y = p.y;
}
V V::div(V p1, V p2) {
V rez(0);
if (p2.y != 0) {
rez.set(p1.y / p2.y);
}
return rez;
}
void inc(V& p) {
printf("%i\n", p.y);
}
int cmpL(V p1, V p2) {
if (p1.y < p2.y) {
return p1.y;
}
else {
return p2.y;
}
}
void V::set() {
y = z;
}
void main() {
system("chcp 1251");
printf("Программу выполнил Вариант №21\n");
V *p1, *p2;
p1 = new V(13);
p2 = new V(22);
V p3(20);
inc(*p1);
p2->set(16);
inc(*p2);
p3 = p3.div(*p1, *p2);
inc(p3);
printf("%i\n", cmpL(*p1, *p2));
system("pause");
}
Answer the question
In order to leave comments, you need to log in
You have set() declared like this void set(int);
, implemented like this void V::set() {
, and called like this rez.set(p1.y / p2.y);
(i.e. set(double)).
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question