Questions tagged [data-members]

In Object Oriented Programming, data members are the data contained by the object. They are also known as fields or member variables.

In Object Oriented Programming, data members are the data contained by the object. They are also known as fields or member variables.

68 questions
0
votes
3 answers

Polymorphism and data members c++

I am having issues with polymorphism I have set these basic classes up methods will be added later but I want the different data members to be accessible from these class. class square { public: bool canBeBought; string name; }; class…
bobthemac
  • 1,172
  • 6
  • 26
  • 59
0
votes
1 answer

how to initialize data member array of a struct with null values?

Here is my struct (It is in private section of Data-structure class): private: // this is the main node pointer array to keep // track of buckets and its chain. struct Node { /** member variables */ unsigned int iCID; std::string…
Abu Shumon
  • 1,834
  • 22
  • 36
-1
votes
2 answers

compiler showing different errors for unassigned struct object field and property

In the below code in line:1, the compiler shows error :"Use of possibly unassigned field 'IntField' " but for line: 2 the error is "Use of possibly unassigned local variable 'structObj' " . Why different error? class Program { static void…
Garvit
  • 55
  • 1
  • 8
-1
votes
1 answer

How should I keep track of the start time of a new clock object?

I'm writing a clock object that can be used to time events in a program and then report on its various times, such as the time it has been running for, its start and stop times and so on. I've written also a clocks object that keeps track of the…
d3pd
  • 7,935
  • 24
  • 76
  • 127
-2
votes
2 answers

What happens to uninitialized class members in c++?

What happens to uninitialized class members in c++? If I have to do this, what should I take care of? #include using namespace std; class Foo { int attr1, attr2; public: Foo (); Foo::Foo () { attr1 = 5; } Foo myThing();
Taylor
  • 1,797
  • 4
  • 26
  • 51
-2
votes
1 answer

JAVA: How do you access data members in a separate class?

I'm really stuck on this code because I can't seem to understand how to access data member into another class in java. I need someone to explain this to me properly. I have my customer class with the following data…
-3
votes
1 answer

C++ questions on Inheritance, privacy, and objects in a shipping program with multiple classes and headers

My program is supposed to print a "to" and "from" address sourced from the EndPoint toString method but I can't quite figure out how to implement it. Here is my code. How do I get the toString method in the Package::Package constructor to print the…
Bren Bailey
  • 11
  • 1
  • 1
  • 8
-4
votes
1 answer

How to access data member of a class member function in main function?

XX.HEADER class ABC { public: ABC(); // constructor int XYZ(int ); int AA; int m } XX.CPP Mat ABC::XYZ(int c) { AA = lambda; return m; } MAIN.CPP int main() { ABC myObject; int labda = myObject.AA; } I want value of AA to be used in main…
hawkeye
  • 349
  • 4
  • 21
1 2 3 4
5