declare function's type as struct c++ -
so have class named user. inside have made struct called flights , want make function in class return struct values of flights. possible? follow. know doesn't work there way?
class user { string name, surname...; struct flights { int miles; double cost; } struct add_miles(reads class); } struct user::add_miles() { return flights; }
i not sure understand requirement see try:
#include<iostream> class user { //string name, surname...; public: struct flights { int miles; double cost; }myflights; struct flights add_miles() { return myflights; } }; int main() { user me; me.myflights.miles=100; std::cout<<me.add_miles().miles; }
Comments
Post a Comment