Category : c++

I need to use obj object inside SLOT function. I can pass obj with [this] in lambda. 1.But need to know if SLOT will keep a pointer variable to obj after newObjptr went out of scope? 2.Will work until newObjptr location re-used at runtime? Object* obj = new Object(); // global object void function() { ..

Read more

I have a C++ class that has a datamember: private: std::vector<std::vector<int>> *edges; Then in my constructor, I do the following: //rows and columns are dynamically set in constructor edges = new vector<vector<int> >(rows*columns, vector<int>()); edges[0].push_back(1); When running my program, I get error: no matching function for call to std::vector<std::vector<int> >::push_back(int) edges[0].push_back(1); ^ I just know ..

Read more

Here is an exercise from C++ Primer 5th Edition: Exercise 13.53: As a matter of low-level efficiency, the HasPtr assignment operator is not ideal. Explain why. Implement a copy-assignment and move-assignment operator for HasPtr and compare the operations executed in your new move-assignment operator versus the copy-and-swap version.(P.544) File ex_13-53.cpp #include <iostream> #include <vector> #include ..

Read more

I’m working on an assignment, and my program is supposed to read in a number and turn it into a triangle. The image below is was is happening vs. what it’s supposed to look like: How do I make it have the right number of rows and stars in each row?? Thanks in advance! // ..

Read more

I’m trying to use GCC to run files and vcpkg to install packages. My beginner problem is: I can’t use the installed library. I explained my way, please help me to find the right way. GCC downloaded from https://jmeubank.github.io/tdm-gcc/download/ and installed in C:gcc. Then for installing vcpkg the https://github.com/Microsoft/vcpkg repository is downloaded and extracted at ..

Read more