#Memory leaks aparently😔
88 messages · Page 1 of 1 (latest)
<source>:1:10: fatal error: Jumper.h: No such file or directory
1 | #include "Jumper.h"
| ^~~~~~~~~~
compilation terminated.
Build failed
ill try, never heard of it tho, so well se how it goes
How are you compiling your code?
Well personally, with visual studio. But i hand it in Via codeGrader, and im not sure how they do it...
thankss
IM getting the error "LINK : fatal error LNK1561: entry point must be defined"
Does jumper have a main function?
Sorry I don't develop on windows so my experience is limited
yeah, i think i fixed it
no no, thank you plenty
so what do i do now that the sanitization is done?
Run it, and if a memory problem arises it will scream at you with great detail
haha ok
i think its telling me its the constructor... but i really dont se whats wrong with it
The constructor doesn't have a definition anywhere
Only a declaration
According to the message
based on the code i put in, is that true?
thats weird then
the file u posted does have Jumper::Jumper(std::string name, int startNr, int totalNrOfJumps)
Where do you have your main? It seems like it didn't compile the file with definitions
whats the output of valgrind?
jumper.cpp line 12
Do you delete the array in the destructor?
i think its right...
What if you assign a jumper to itself?
Also I assume of you have a copy constructor as well?
well, im not sure.... i think it just returns a pointer to itself
so that valgrind error btw tells you that that memory is still not freed somewhere, it should also report this at the bottom
Oh woops, didn't see the other != this
yes, ignore the other ones, the are just due to the testing files i think
or maybe u meant this one:
Well that’s not a copy constructor
can you please send your files
you have done many edits and we can't track what you did
This question thread is being automatically closed. If your question is not answered feel free to bump the post or re-ask. Take a look at !howto ask for tips on improving your question.
This question thread is being automatically marked as stale.
send the files where you wrote the base class Competitor
you have a missing virtual destructor in the base class Competitor
this is exactly why you get leaks
once implemented, all derived classes will also have an implicit virtual destructor
oh wait, so you do have a virtual destructor
this is correct
show me your main.cpp where you use these classes
how do you create them and how do you destroy them
the test cases do not deallocate created objects
they are leaking the memory
the author of these tests is a fool
haha
find them and politely ask why the tests have leaks
yea, ig ill mail them
thanks for your help
i was unsure wether it was my code or not so helps alot
TEST_CASE("test of toString() for Jumper using base class pointers")
{
Competitor* compTwo = new Jumper("Ken", 200, 3);
compTwo->addResult(4.56);
compTwo->addResult(7.12);
compTwo->addResult(6.54);
REQUIRE(compTwo->toString().find("Ken") != std::string::npos);
REQUIRE(compTwo->toString().find("200") != std::string::npos);
REQUIRE(compTwo->toString().find("4.") != std::string::npos);
REQUIRE(compTwo->toString().find("7.") != std::string::npos);
REQUIRE(compTwo->toString().find("6.") != std::string::npos);
}
10/10, will test for leaks again
who calls delete on compTwo?
NO ONE!
hahahaha
Let me guess - the teacher is using Java mainly, but he had to learn and teach C++ because there's a shortage of staff?
in some places there is delete for cleanup, in others there isn't
that might be it, honestly i have no idea
@shrewd perch Has your question been resolved? If so, run !solved :)
!solved