Questions tagged [member-access]

63 questions
1
vote
2 answers

Python: referencing class object list of lists

I am fairly new to python. I have tried to define a class, I then want to create an instance from a file, then refer to specific pieces of it, but cannot seem to. This is Python 3.3.0 Here's the class.... class Teams(): def __init__(self, ID =…
granger
  • 83
  • 1
  • 8
1
vote
3 answers

What is the use of overloading the member access operator?

Possible Duplicate: Operator overloading The member access operator -> can be overloaded to return a pointer to a data member, or some other variable. Where is this feature used ? What coding problems does it solve or alternately, what does it…
asheeshr
  • 4,088
  • 6
  • 31
  • 50
0
votes
1 answer

error: member access into incomplete type 'WINDOW' (aka '_win_st')

I have problems accessing _maxx, it says: ./ScoreBoard.hpp:20:38: error: member access into incomplete type 'WINDOW' (aka '_win_st') mvwprintw(score_win, 0, score_win->_maxx - 10, "%11llu",…
0
votes
0 answers

Converting json into member accesses and function calls C++

I have a custom list class capable of storing recursive lists. There is a json file that is parsed during runtime which will contain information about what functions to call on what lists. I am using nlohmann::json library For example: class…
0
votes
0 answers

Error: passing X as 'this' argument discards qualifiers

Turns out I don't really understand const.. So I have this (minimized) code sample. When I try to call a function which has access to members of a const class object (-> GetData()) I get the following error: Error (gcc 11.2): :129:28: error:…
glades
  • 3,778
  • 1
  • 12
  • 34
0
votes
2 answers

Overloading ostream << operator for a class with private key member

I am trying to overload the ostream << operator for class List class Node { public: int data; Node *next; }; class List { private: Node *head; public: List() : head(NULL) {} void insert(int d, int index){ ... } ...} To my…
0
votes
0 answers

Structure Array as a parameter and it's member access

This code is written in C. The first line of Node_reset() function occurs an error. (Structure array is allocated dynamically in main function.) I think there's something wrong in member-access of Node_reset(), also Create() might occur same kind of…
0
votes
1 answer

avoid member access for shared base state

Suppose I have a base class that is an abstract interface, and two derived classes, which inherit a certain state from the base class. I want to change which derived class I'm using at run-time, but I want to preserve the shared state. class…
user12326560
0
votes
3 answers

Const class object with a pointer member

let's have an example program: struct Example { int* pointer; Example(int* p) : pointer(p) {} }; int main() { int var = 30; const Example object(&var); object.pointer = &var; // error *object.pointer = var; } I do know why…
Vatnax
  • 11
  • 1
0
votes
1 answer

C++ - friend operator cannot access private data members

I am trying to overload an operator for a class: #include using namespace std; class Complex{ float re, im; public: Complex(float x = 0, float y = 0) : re(x), im(y) { } friend Complex operator*(float k, Complex c);…
Hadi GhahremanNezhad
  • 2,377
  • 5
  • 29
  • 58
0
votes
3 answers

Accessing elements of a nested structures

when I execute the following code I get an error message for this line scanf("%s",A.(T+i)->CNE) error message : expected identifier before '(' token| can I know what is the problem? thanks in advance. typedef struct date { int day; int…
LEARNER
  • 123
  • 1
  • 9
0
votes
1 answer

How do I access from template class A a struct declared as private field in template B class in c++?

There is following c++ raw code: template class A { private: // here I want to access B::SomeStruct to create SomeStruct field in class A }; template class B { private: template friend class A; struct…
0
votes
0 answers

Set specific member access behaviour

I want an specific behaviour to my classes access, and although there are workarounds and I can handle the situation without achieving that specific behaviour, I was finally wondering if its even possible to achieve that in c#. So I have 3 classes…
rustyBucketBay
  • 4,320
  • 3
  • 17
  • 47
0
votes
2 answers

Why overloaded de-reference operator doesn't work the same way as the arrow operator?

Again reading C++ primer 5 ed. by lipmann now I've read about Member access operators overloading. Everything is clear to me except: struct A { int& operator* () {return *p;} void foo()const{cout << "A::foo()\n";} int* p = new…
Maestro
  • 2,512
  • 9
  • 24
0
votes
1 answer

Is there a technical reason why I cannot declare a public array in a VBA class?

I just discovered that it's apparently not possible to declare a public array in a VBA class while it is fine to declare it private. I am wondering if this is has a technical reason or if this is a design choice on Microsoft's part. Either…
René Nyffenegger
  • 39,402
  • 33
  • 158
  • 293