You may call me crazy after reading this post, but I really ask you to trust me when you read what I say here. In an attempt to understand situations in which a memory leak or other errors may occur, I wrote the following code and tried compiling on my computer,
#include <iostream> using namespace std; class game { int x; public : char *s; char read(); char manipulation(); }; char game :: read() { char string[100]; cout<<"Enter name "; cin>>string; s = string; cout<<"Name is "<<&s<<endl; } int main() { game games,games1; // games.read(); cout<<"Name is "<<games.s<<endl; return 0; }
If I execute games.read () in my main article, my BITDEFENDER antivirus software shows me the following error: "BITDEFENDER detected an infected element in c: / C ++ / inline.exe. Virus name: Gen: Variant.Graftor.51542. File was cured for your protection. "
inline.cpp is the name of my program. If I delete this line "games.read ()", it compiles in order. Is a pointer causing a memory leak somewhere?
source share