C++ noob question: pointers and overloaded [] -


I am staring at this for a while and I am not getting too far. There are three sections from the API using FruitBackett Factory, Fruitbacket, and Fruit. My goal is to make a fruit baskets and to recover the fruit is the FruitBasetsFactor. According to HPP:

  Config Frenbuskate * Fixbasket () console;  

and then fruitbase HPP

  size_t getNumFruits () const; Brace fruit & amp; Operator [] (size_t index) const;  

So here is my starting code:

  Falbettext Factbet Factor; // Whenever I want an object instead of the pointer, I try the unusable attribute of the Parent Confect Fractal Basket Faultbacket = * (Futbeset Factor Fretbetbasket ());  

But here I get an error "Error C2248: Can not use private member declared in 'Fruitbusket :: Flebusket': Class 'Frabsket'" . Should not it work?

So, okay ... I reuse my code.

Fruitbacket Factor Falbet Factor; Const Falbacet * Fruitbasket = Falbesetfactor.GetfootBackett (); If (Falbessext-> Matching Fruit ()> (); {// Using (* Frasbanket) [0] Sounds Foolish Fruit Fruit = (* Falbacet) [0]; }

and failed : "Error C2248: 'fruit :: fruits': can not use private member declared in class 'fruits'

Then, work on another again

FruitbacketfactorFablesbasefactor; Const Falbacet * Fruitbasket = Falbesetfactor.GetfootBackett (); If (Falbessext-> MillenFruits ()> gt; 0) {// This is just ridiculous ... I have some incorrect processed fruits * fruits = & amp; (Falbesset-> Operator [] (0)); }

looks misunderstood as part of the code, it actually works, but I can do just what I think should be the most obvious thing?

Fruitbacket Factor Falbet Factor; Arc fruitback flowerbuscht = * (footballsetfactor.getfootbasket ()); If (fruitbeset.getnamuffites ()> gt; 0) {fruit fruit = flowersbuscuts [0]; }

Resolution:

The copy constructors were actually blocked for both fruitbackets and fruits, I was able to make reference by calling them as the following :

  fruitbeatfactor fetabetsfactor; Concert Fricketbusch & amp; Fruitbuskate = * (footballsetfactor.getfootbasket ()); If (failbyset.gatnamfuites ()> gt; 0) {cst and ft; Fruit = flowerbasket [0]; }  

but here's an error error C2248: 'flowersbusk :: Fruitbuskets': Can not use the private member declared in the square 'Fruitbasket'. . Copy creator is inaccessible for

flowersbuskate . Have you declared the copy constructor private or protected for this class?

const fruit * fruit = & amp; (Falbet-> Operator [] (0));

This can be written more appropriately as:

  const fruit * fruit = & amp; (* Fultbaseet) [0];  

The indicator should be dereferenced so the subscript operator has been applied to the class-type FruitBasket object and the indicator is FruitBasket .

If you apply a pointer's subscript, the built-in subscript operator is used and the pointer is considered as a pointer to an array of fruitbackets objects.


Comments