darek9576's Profile User Rating: ***--

Reputation: 198 Stalwart
Group:
Active Members
Active Posts:
1,687 (1.01 per day)
Joined:
13-March 10
Profile Views:
42,180
Last Active:
User is offline Sep 26 2014 03:18 AM
Currently:
Offline

Previous Fields

Dream Kudos:
0
Icon   darek9576 has not set their status

Posts I've Made

  1. In Topic: Dynamic array of pointers syntax

    Posted 24 Sep 2014

    Thanks for the answer. The confusion i guess comes from the fact of too many "*".

    So, first question is: does the TYPE between "new" and "[size]" indicate what type the array will hold?

    So,
    new T[size];
    


    means that we will have an array of type T allocated on the heap?
    new int*[size];
    new unique_ptr<Person>[size];
    


    means that we will have an array holding (as its elements) values of type int* and unique pointers to Person object on the heap?


    If that is the case, why dont we have the syntax:

    int* a = new int*[size];


    Why do we need the second asterisk as in int**.

    Because i believe to dynamically allocate an array of unique pointers we would do:

    std::unique_ptr<int>* upa = new std::unique_ptr<int>[size]; (again, not sure if corret)

    Hope you can confirm the first question and explain the last one.
  2. In Topic: Vector and copy constructor

    Posted 27 Aug 2014

    Thanks for the answers.
    @CTphpnwb - the only reason i used pointers to strings was just to learn how exactly vectors and copy constructors work. I do realize that usually it's not what should be done.
    @vividexstance - i am aware of move semantics and smart pointers but for now they are too advanced.
  3. In Topic: why do we use private fields

    Posted 9 Aug 2014

    What if you have a Person class and setAge() function and the outside uses it and does:

    personObject.setAge(1000);

    I never heard of anyone living thousand years. Read about encapsulation.
  4. In Topic: C++ templates and operator overloading basics

    Posted 1 Aug 2014

    Why would the constructor that does the following compile:

    amount = 0;


    What if amount is of type Apples. Can someone explain or is it just an error in the tutorial.
  5. In Topic: XML Encoding/Decoding

    Posted 19 Jun 2014

    I solved my problem in a different way.

My Information

Member Title:
D.I.C Lover
Age:
Age Unknown
Birthday:
Birthday Unknown
Gender:

Contact Information

E-mail:
Click here to e-mail me

Friends

darek9576 hasn't added any friends yet.

Comments

darek9576 has no profile comments yet. Why not say hello?