Skip to main content

All Questions

Tagged with
Filter by
Sorted by
Tagged with
0 votes
1 answer
495 views

member "Node::next" (of a friend class) is inaccessible

I am building my own LinkedList, because I need a special Node that holds more data. I specify that my Node class is a friend of the LinkedList class, but it doesn't seem to allow me to access the ...
Jacob Hornbeck's user avatar
1 vote
1 answer
449 views

Why can we access private data members class using pointers, without using members friend function other members in the class?

As you know, private members can only be accessed by other members in the class class DateClass // members are private by default { int m_month; // private, can only be accessed by other members ...
justANewb stands with Ukraine's user avatar
0 votes
2 answers
203 views

accessing private members without using friend class [duplicate]

I have a homework in which: we have this code: #include <iostream> using namespace std; class Test { int x; char y; public: Test() :x(0), y(0) { ; } }; int main() { Test t; ...
hanie's user avatar
  • 1,885
-1 votes
1 answer
1k views

How do I declare a pointer to an array of Class objects, within the private members of a DIFFERENT Class?

My aggravation with this problem has been compounded largely with the heavy use of vector as the cure-all in all the other solutions. Let me preface this problem by saying that I am REQUIRED to use ...
Aaron DeWitt's user avatar
-5 votes
3 answers
49 views

How private data member is used by an inherited class object?

Do private members are also inherited? Why get() function was able to read variable n #include <iostream> using namespace std; class base { int n; public: void get() { cin &...
user avatar
0 votes
1 answer
822 views

member function LinkedList::deleteNode may not be redeclared

I've been trying to fix this error member function LinkedList::deleteNode may not be redeclared outside its class over and over again. I already made sure each member function has two } at the end of ...
YesMachinesHaveFeelings's user avatar
-5 votes
3 answers
133 views

why c++ allows pointers if they can generate problems like accessing private members?

I have read about c++ pointers and their pitfalls, one of which is that one can access private data members of other class objects using pointer hacks as mentioned here and here. Surely pointers in c++...
dedman's user avatar
  • 908
2 votes
2 answers
2k views

Providing pointer to private member from within class

I realise that providing a method which returns a pointer to a private method breaks encapsulation, and exposes the field to anyone who uses the class. However, suppose the following: You have a ...
19172281's user avatar
  • 237
-1 votes
3 answers
108 views

Why we have to mention data type in front of address of the object to access the private members of a class in C++?

I'm trying to access the private members with the help of pointers. I want to know that why we mention dtype in front of (int*)&t? class Test { private: int data; public: Test() { ...
rida's user avatar
  • 41
4 votes
2 answers
243 views

Trouble with Nodes and Linked Lists

I have an assignment where I am supposed to create methods to insert and remove nodes in a doubly linked list. However I am a little rusty with my C++. I am getting an error from my front and rear ...
GreenFerret95's user avatar
-2 votes
2 answers
3k views

Linked List private pointers C++ [closed]

I am having trouble understanding how to use pointers when they are in "private". mostly I don't know how to get and set values for pointers I want to create a head and tail node that have no ...
David Walker's user avatar
-1 votes
3 answers
65 views

Why class object as pointer gives segmentation error, when the usual class object does not

I don't understand as to why the code below gives a segmentation fault upon use of a pointer object. The code works fine, if non-pointer object is used, but gives a segmentation fault if pointer ...
cdjk's user avatar
  • 3
0 votes
3 answers
2k views

How can I copy a pointer to another class within a class to another pointer in C++?

In other words, how can I take a pointer of a class-type that is within a different class and copy it to another pointer of the same class-type. Here's an example: class Bananas { private: ...
Grant Miller's user avatar
  • 29.1k
0 votes
1 answer
59 views

Passing references to pointers

I'm having an issue with a private recursive helper function which I am passing a reference in a pointer to. I am getting an error that says "No instance of overloaded function "insertSymbol" ...
23ChrisChen's user avatar
0 votes
1 answer
692 views

Returning a private function pointer in Battleship game c++

Happy Saturday! I am trying to teach myself C++ so I am doing a Battleship program. This version is fairly standard. The player enters the coordinates of a cell to try to hit a ship. The program ...
user avatar

15 30 50 per page