Search:

Type: Posts; User: Vespasian_2

Page 1 of 5 1 2 3 4

Search: Search took 0.01 seconds.

  1. Replies
    9
    Views
    8,115

    I think I got you, thanks!. Its a lot more...

    I think I got you, thanks!. Its a lot more nuanced than I initially thought.
  2. Replies
    9
    Views
    8,115

    I think I got you. Its a lot more nuanced than I...

    I think I got you. Its a lot more nuanced than I initially thought.
  3. Replies
    9
    Views
    8,115

    OK, I assume that this is also a composition...

    OK, I assume that this is also a composition between Driver and license?



    class Driver
    {
    // ...
    private:
    DrivingLicence *licence = new DrivingLicense;
    std::vector<Car*> cars;
  4. Replies
    9
    Views
    8,115

    Thats the problems i'm having. I cant think of...

    Thats the problems i'm having. I cant think of the minimum C++ example that demonstrates the difference between the two. I just know through a textbook that what I included above is composition.
  5. Replies
    9
    Views
    8,115

    I get that but how would the difference in...

    I get that but how would the difference in implementation look? Ill give an example. Ive made 1 superclass called Asset and 3 subclasses which derive from Asset and they are called Stock, Bond and...
  6. Replies
    9
    Views
    8,115

    Aggregation vs Composition

    I have read all StackOverflow articles. Many other articles. Book posts and blogs and still struggling to understand the difference between the two.
    From what I know:

    Composition means that if A...
  7. Got it. Thanks again Laserlight, quality response...

    Got it. Thanks again Laserlight, quality response as always.
  8. Object's array on the stack vs array on the heap

    Is there any benefit to having this:

    OPTION 1:

    class stackArray{
    static const int STACK_SIZE = 3;
    public:
    stackArray(){
    item = new int[STACK_SIZE];
    item[0] = 100;
  9. Replies
    4
    Views
    4,827

    Ok, but is line 20 and 21 specifically a memory...

    Ok, but is line 20 and 21 specifically a memory leak? I dont see comments next to them in your comments. My rationale is as follows:
    Line 20: name = n; // name USED to point to an area of heap...
  10. Replies
    4
    Views
    4,827

    Is this a memory leak?

    #include <iostream>
    #include <string>
    #include <stdlib.h>
    #include <string.h>


    using namespace std;


    class Student{
  11. Thanks all. Makes sense.

    Thanks all. Makes sense.
  12. If EOF evaluates to -1 why does it break a while loop

    In the conditional statement in the while loop below, the extraction operator is used on an input stream object "i". When the file reaches an EOF, the loop breaks.

    This doesnt make sense as I...
  13. Replies
    5
    Views
    2,495

    Ah I never saw it that way. Interesting, makes...

    Ah I never saw it that way. Interesting, makes sense now that I think about it.
  14. Replies
    5
    Views
    2,495

    I understand. Is there any design rationale...

    I understand. Is there any design rationale behind this (Edit: I mean why was the language designed like this)? If you could evaluate an array name to a modifiable address, you would only lose the...
  15. Replies
    5
    Views
    2,495

    Deleting first character of an array

    Suppose we have:

    char myString[] = "This is a test";

    If I want to delete the first character of an array, I am always tempted to do:
    myString1++

    The above doesn't work. What does work...
  16. I feel like an idiot. You basically fixed the...

    I feel like an idiot. You basically fixed the error before I asked the question, thats a first ive ever seen on a forum.
  17. OH MY WORD EMBARRESING. Sorry you were right...

    OH MY WORD EMBARRESING. Sorry you were right tabstop.

    There are no more errors
  18. Haha yeah I just saw your reply but I fixed that...

    Haha yeah I just saw your reply but I fixed that too it seems there is still the crashing error
  19. Ah thanks! Silly me. Im new to templates as you...

    Ah thanks! Silly me. Im new to templates as you may see.

    Okay Ive just put it in a header only file but now Im getting an error printing out the Object:


    #include <iostream>#include "matrix.h"...
  20. Cannot Instantiate Object from Templated Class

    I have a Matrix Class defined as follows:

    #include "matrix.h"

    template <class Object>
    Matrix<Object>::Matrix(int row, int col)
    {
    rows = row;
    cols = col;
    array.resize(row);
  21. Thanks alot! I didnt know a const would cause a...

    Thanks alot! I didnt know a const would cause a compilation error! I thought at most it was just to remind the reader that it is a value that should not change.
  22. Insertion Operator overloading works on some objects but not on others

    Hi all,

    I have overloaded an insertion operator which works on the object within which it is defined (see line 47).

    But when I use this insertion operator on an object that contains the other...
  23. Replies
    5
    Views
    4,533

    Thanks Laserlight that kinda makes sense. But...

    Thanks Laserlight that kinda makes sense. But which one of them is more specific as a description for the numeric arrays as an example? What I mean by that is, is there ever a case where the...
  24. Replies
    5
    Views
    4,533

    Uninitialized numeric arrays in C++

    I am using a numeric array as an example to my core question.

    What happens when an array declaration statement does not provide an initial value for each of the elements in a numeric array?

    I...
  25. if(strcmp(string1, string2)) Equivalent to if(strcmp(string1, string2) == 0)

    Is this statement:

    if(strcmp(string1, string2))

    Equivalent to

    if(strcmp(string1, string2) == 0)

    My understanding is case 1 is the correct way to execute an if statement if two strings...
Results 1 to 25 of 110
Page 1 of 5 1 2 3 4