[Solved] C++ Accessing Another Class Member [closed]

Simply add a getter method int get_x() to Class1 #include <iostream> #include <conio.h> using namespace std; class Class1{ private: int x; public: Class1(); void Display(); int get_x(); }; int Class1::get_x() { return x; } class Class2{ private: double z; public: Class2(); void Display(); Class2 Add(Class1); }; Class1::Class1(){ x = 1; } Class2::Class2(){ z = 5; … Read more

[Solved] expected ‘)’ before object. class does not name a type [duplicate]

For starters, you should remove #include “Car.h” from Color.h. It creates an unnecessary circular include, and the compiler hits Car(Color a) before it knows that Color is a class. You also need to include the header <string> to output a string to cout. Next time, maybe don’t insult the people who are helping you. solved … Read more

[Solved] Why is this code not taking input for “Designation”?

When reading from standard input, do not mix C library functions, such as fgets(), and C++ std::cin operators. The C library knows nothing about what the C++ library is doing. Change your code to use only stdin, or only std::cin, to read standard input. solved Why is this code not taking input for “Designation”?

[Solved] what components do exist in any java class? [closed]

I think this is everything that every Java class has: A class name. A class access … implicitly package private, if you don’t specify one. A package … implicitly the default package, if you don’t specify one. A superclass … implicitly java.lang.Object, if you don’t specify one. A body which may be empty. A constructor … Read more

[Solved] Using int main(int argc, char **argv) in c++ [closed]

You haven’t actually provided code that exhibits your problem but, to answer your question, ways to pass argv[2] as a string to a function include #include <cstring> #include <iostream> void func(const char *s) { // treat s as a zero terminated string if (std::strcmp(s, “Hello”) == 0) { std::cout << “You said hello\n”; } } … Read more