My executable was 364kb in size. It did not use a Vector2D class so I implemented one with overloaded operators.
I changed most of my code from
point.x = point2.x;
point.y = point2.y;
to
point = point2;
This resulted in removing nearly 1/3 of my lines of code and yet my exe is still 364KB. What exactly causes it to grow in size?
...
I was pretty sure that the answer to that question was, "Never, ever can a template be the copy constructor."
Unfortunately, I just spent 3 hours figuring out why I was getting a warning about recursion, tracked it to the copy constructor, watched the debugger go insane and not let me look at the recursive code, and finally tracked it d...
Perhaps this is a stupid question, but I'm trying to use BGL's dijkstra_shortest_paths, and, in particular, to use a field of my Edge bundled property as the weightmap. My attempts have currently led to tens of pages of compiler errors, so I'm hoping that someone knows how to help me. This is essentially what my code looks like:
struct ...
const int NUMB = 4;
int n[] = {5,6,7,8};
// create a vector of strings using the n[] array
vector<int> partnums(n, n + NUMB);
The class functions vector name(src.begin, src.end)
Create a vector initialized with
elements from a source container
beginning at src.begin and ending at
scr.end
According to the book,
The vec...
hi i just started to learn c++. I'm trying to figure out how to make a variable change depending on another variable. It shows a strange answer when i try it idk where its getting it from. anyways i'll just put my code in here and hope someone understands what i am doing.
#include <iostream>
long int mult (float hours,float payrate,fl...
does the knowledge of more functions provided by microsoft to use; makes you a good programmer? what should one do after learning the c++ concepts to become a good programmer?
...
As I understand, the LLVM Core project consists of:
Compiler - converts my source code to LLVM IR
VM - executes the compiled IR code
How can I embed this VM to my C++ application?
...
The following testing code does correctly in VS either with debug or release, so does it in gcc. It also does correctly for ICC with debug, but not when optimization enabled (-O2).
#include <cstdio>
class tClassA{
public:
int m_first, m_last;
bool isEmpty() const {return (m_first == m_last);}
void updateFirst() {m_first = m_f...
Is the following code legal in C++. Accessing a friend class member public method? I know this sounds confusing, and the best way to show it is in code. I was wondering if the TestClassC::Method() is valid in the code below?
I've compiled (g++) and it works, however, I run into a situation, where it produces a segmentation fault on othe...
My application has a standard top level window for the application. I need to force a repaint of the window chrome (otherwise known as the non-client area of the window). I do not care if the client area is also repainted or not but the chrome itself needs to be forced to repaint.
In particular I need this to work on Windows 7. Whether...
Fully aware, that the question I am asking is outside the purview of the C++ Standard, I am curious to know why GCC throws the same error twice? I know why the error is there, but am looking forwards to understand why the duplication in error message.
#include <iostream>
using namespace std;
struct A{
virtual void f1() = 0;
};
stru...
I'm attempting to make an x64 build of a project with Visual Studio 2005. It's currently failing with linker error C1905, 'Front end and back end not compatible (must target same processor).'
From what I gather, this is essentially saying that my x64 build is attempting to link with x86 modules. Unfortunately, this project links with a ...
I'm working on a C++ and Objective C iPhone Project. I'm using git as my version control system.
The codebase has been growing quite a bit, so I would like to add Doxygen to the project. The problem is that I'm not sure about what would be the best approach to do it.
I've thought about a couple of options:
1) Create the Doxygen HTML d...
I am trying to write a class template that provides a comparison operator between two instatiations with different template types. As is often the case, this operator is a non-member friend. A simplified example of what I am trying to achieve can be seen below.
template<typename T>
class Wrapper {
// Base type, which must have a val()...
Hi,
I have a pthread waiting on a condition variable using pthread_cond_wait. It's waiting for data from a queue structure that is filled by another thread. I want to kill this thread, preferably without pthread_kill. On Linux and WinPthreads doing a pthread_cancel(); pthread_join() is enough to kill it. However, on OS X it hangs on...
I'm drawing 2D, concave, sometimes multicontoured, sometimes self intersecting polygons with OpenGL.
Here is a sample:
Right now, I take the points which if connected would result in the polygon's outline. Then I put these into the GLUTesselator where triangles come out. I then make texture coordinates and texture the polygon.
The abs...
What books should you read to improve your code and get used to good programming practices after getting a taste of the language?
...
/*1*/ const char *const letter = 'A';
/*2*/ const char *const letter = "Stack Overflow";
Why is 1 invalid but 2 valid?
letter is a pointer that needs to be assigned an address. Are quoted strings addresses? I'm assuming this is why #2 is valid and that single quoted strings are not considered addresses?
Also, what is the difference...
I read few documents about Mutex and the only Idea I have got still is This helps preventing threads from accessing a resource that is already being used by another resource.
I got from Code snippet and executed Which Works fine:
#include <windows.h>
#include <process.h>
#include <iostream>
using namespace std;
BOOL FunctionToWriteT...
I have a C# application which calls a function in a C++ dll. This function can throw various exceptions which inherits std::exception. I currently catch these exceptions like this:
try
{
//Call to C++ dll
}
catch (System.Exception exception)
{
//Some error handling code
}
My first question is will this code catch all std::exce...