How would I do this
class test {
public:
int* num;
};
int main() {
test *d = new test;
d->num = new int;
d->*num = 3;
cout << d->*num;
}
How would I do this
class test {
public:
int* num;
};
int main() {
test *d = new test;
d->num = new int;
d->*num = 3;
cout << d->*num;
}
Jump to PostTry something like this
#include <iostream> class test { public: int* num; }; int main() { test *d = new test; d->num = new int; *(d->num) = 3; std::cout << *(d->num); }
Try something like this
#include <iostream>
class test {
public:
int* num;
};
int main() {
test *d = new test;
d->num = new int;
*(d->num) = 3;
std::cout << *(d->num);
}
#include <iostream>
class test {
public:
int* num;
};
int main() {
test *d = new test;
d->num = new int;
*d->num = 3;
std::cout << *d->num;
}
Edit: Beaten to the punch by seconds!
Yes, I feel so stupid. I could have figured it out myself :(
Thanks for help :)
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.