-4

I have a pointer declared in my header file witch i am initializing in my constructor to point towards and array. However I cant seem to get it to point towards the array as a whole instead i only see the first value in the debugger. Is there anyway to make it show everything or do i have to acces it in the blind.

I am using Visual Studio 2013

.h

class myClass{
    public:
        myClass();
        ~MyClass();
    private:
        double* categories;
}

};

.cpp

double array[5] = {0,1,2,3,4};

categories = new double[5]
categories = array;

What confuses me is when i do it all in .cpp i can see everything just fine :/

double g[2] = { 9, 8 };
double(*j)[2] = &g;
  • "when i do it all in .cpp" - you managed to pick a difference that is completely irrelevant. – Karoly Horvath Apr 09 '15 at 11:48
  • 1
    Your question appears to be one about how to use the Visual Studio debugger. A pointer, being just a memory address, can _only_ point to the start of an array. – 200_success Apr 09 '15 at 11:50
  • @KarolyHorvath This is my first time ever doing anything in C++ and since we cant know everything right from the bat i dont see the reason to be rude about my lack of knowledge on pointers. And since when i use the debugger on the other chunk of code it shows [0,1,2,3,4] – Johan Holmberg Apr 09 '15 at 12:02
  • @JohanHolmberg: It was a mere observation. If you percieve it as rudeness, well, that's your problem. – Karoly Horvath Apr 09 '15 at 12:05
  • @KarolyHorvath I think most would disagree but no need to argue :) – Johan Holmberg Apr 09 '15 at 12:13
  • yes, most people are f.ing pansies here... – Karoly Horvath Apr 09 '15 at 12:37

1 Answers1

1

A pointer is the same thing as an array, without the size information.

So it's normal it points to the first value of the array. The answer to your question can be found here: How to display a dynamically allocated array in the Visual Studio debugger?

Community
  • 1
  • 1
coyotte508
  • 9,175
  • 6
  • 44
  • 63