1

why does the compiler give me a warning in line 17:

Object_OutherClass.Object_InnerClass.SetZwischenspeicher(17); 

It says:

C6001: Not initialized storage is being used.

If anyone could help me that would be so cool but pls dont say Im a Noob, im just learning

#include <iostream>
using namespace std;

class OutherClass {
 public:
  class InnerClass {
   private:
    double Zwischenspeicher;

   public:
    void SetZwischenspeicher(double zahl) { Zwischenspeicher = zahl; }
    double getZwischenspeicher() { return this->Zwischenspeicher; }
  } Object_InnerClass;
};
int main() {
  OutherClass Object_OutherClass;
  Object_OutherClass.Object_InnerClass.SetZwischenspeicher(17);
  std::cout << Object_OutherClass.Object_InnerClass.getZwischenspeicher()
            << std::endl;
  cin.get();
  return 0;
} 
sigmund
  • 39
  • 6
  • https://learn.microsoft.com/en-us/visualstudio/code-quality/c6001?view=vs-2019 – sigmund Aug 03 '19 at 11:50
  • Ok this means i have to define a constructor an call it by declaration ? – sigmund Aug 03 '19 at 11:51
  • 1
    @sigmund The code looks fine to me. [I don't get any warnings.](https://gcc.godbolt.org/z/LHB2KM) What version of VS do you use? – HolyBlackCat Aug 03 '19 at 11:58
  • 2
    There's no uninitialized usage in the shown code. The compiler is wrong. – Sam Varshavchik Aug 03 '19 at 11:59
  • Im using Microsoft Visual Studio Community 2019 - I dont know exact version – sigmund Aug 03 '19 at 12:01
  • Which variable is mentioned in the error [message](https://learn.microsoft.com/en-us/visualstudio/code-quality/c6001?view=vs-2019) ("warning C6001: using uninitialized memory "). – 1201ProgramAlarm Aug 03 '19 at 17:47
  • Please avoid `using namespace std;`. It is considered bad practice and will ruin your life. See [Why is “using namespace std;” considered bad practice?](https://stackoverflow.com/q/1452721) – L. F. Aug 04 '19 at 03:34

0 Answers0