Hi,
I am trying to dynamically assign a 2d array to a pointer in a constructor initialize.
FooBar::FooBar()
: _array( new int[10][10] )
{ }
int **_array;
However this does not work. I understand that multidimensional arrays are allocated a bit differently. Is anyone able to elaborate on this with an explanation?
Thanks in advan...
Hi, I have a problem with the layout of 2 controls on my window.
I have a status bar which is located at the bottom of the window. Now I want to create a toolbar that will be located at the bottom also, but above the status bar. I used the CCS_BOTTOM style but the problem is is that the toolbar goes behind the status bar and becomes bar...
I'm trying to convert an integer to a string right now, and I'm having a problem.
I've gotten the code written and working for the most part, but it has a small flaw when carrying to the next place. It's hard to describe, so I'll give you an example. Using base 26 with a character set consisting of the lowercase alphabet:
0 = "a"
1 = "...
Hi,
I have a Solr box which is fed by a PHP cronjob right now.
I want to speed things up and save some memory by switching to a C++ process.
I don't want to reinvent the wheel by creating a new library.
The only thing is I can't find a library for Solr in C++.
Otherwise I will have to create one using CURL probably.
Does any of ...
Hi i tried to connect oracle 10g in c++ using occi, the environment was created successfully, but when trying to create a connection
ora 24960 came and it said that the attribute OCI_ATTR_USERNAME is greater than the maximum allowable length of 255
I am very new to c++ and occi so please help me in that issue
Thanks in advance
...
Hey, so if I have a Base class and 2 derived classes...
class Base
{
virtual void Output()
{
cout << "OUTPUTTING A BASE OBJECT" << endl;
}
};
class Derived : public Base
{
void Ouput()
{
cout << "OUTPUTTING A DERIVED" << endl;
}
};
class OtherDerived : public Base
{
};
As I understand it, if I try to call O...
I recently debugged a strange C++ problem, in which a newly declared vector somehow had a size of 477218589. Here's the context:
struct Triangle {
Point3 a,b,c;
Triangle(Point3 x, Point3 y, Point3 z) : a(x), b(y), c(z) {}
Vector3 flat_normal() { return (a-c)^(b-c); }
};
vector<Triangle> triangles;
Calling triangles.size()...
Here the code
#include <iostream>
#include <conio.h>
using namespace std;
template <typename T> class grid
{
public:
grid();
~grid();
void createCells();
private:
T **cells;
};
int main(int argc, char **argv)
{
grid<int> intGrid;
_getch();
re...
how hard would it to make software for a webcam like gateway usb 2.0 web cam. i would like to ask it to give me pics when i ask. i know i could but how do i? what would i use, i can program in c++ so if i could use that it would be nice.
...
In Google's Protocol Buffer API for Java, they use these nice Builders that create an object (see here):
Person john =
Person.newBuilder()
.setId(1234)
.setName("John Doe")
.setEmail("[email protected]")
.addPhone(
Person.PhoneNumber.newBuilder()
.setNumber("555-4321")
.setType(Person.PhoneType.HOM...
I've been struggling with understanding how C++ classes include other classes. I'm guessing this is easier to understand without any preconceived notions.
Assume my two classes are Library and Book. I have a .h and .cpp file for each. My "main.cpp" runs a simple console app to use them. Here is a simple example:
//Library.h
#ifn...
How can operator bool() cause an error when declaring operator std::string in a class and also serving as an implicit conversion to string by itself?
#include <iostream>
#include <string>
using namespace std;
class Test {
public:
operator std::string() { cout << "op string" << endl; return "whatever";}
operator bool() { cout <<...
Is there a way to pass
std::map<std::string, float>
as an argument to a macro?
(the problem is that the "," is used by the macro to split
std::map<std::string
and
float>
as separate arguments. I would like to avoid this.
...
I have a constructor of the form:
MyClass(int a, int b, int c);
and it gets called with code like this:
MyClass my_object(4.0, 3.14, 0.002);
I would like to prevent this automatic conversion from double to int, or at least get warnings at compile time.
It seems that the "explicit" keyword does not work in these case, right?
...
I have 3 questions. I am making a C++ executable to launch a Perl program I made. I will compile it for Winows, Mac OSX and Linux. It's pretty much just: system("perl progam.pl");
When compiled with Mac OSX, the program starts in ~. How would I get it to start in the dir it was launched from, or is it just a problem with the compiler?
...
Possible Duplicate:
C++ new int[0] will it allocate memory?
What is supposed to happen when i do this:
int * MakeArray( std::size_t Size ) {
return new int[ Size ];
}
MakeArray( 0 );
We had this is out code (using VC++ 2005), and the debug-heap complained about a memory-block of size 0 that was not deallocated. Is it ...
I want to use the MallocDebug app to find some memory leaks in my app. I'm running Mac OS X 10.6.2. Whenever I try and following the instructions listed in this guide, I get the following error:
dyld: could not load inserted library: /usr/lib/libMallocDebug.A.dylib
Trace/BPT trap
I have verified that the .dylib file exists, and I get...
I have the following code
#include <iostream>
#include <vector>
using namespace std;
int distance(vector<int>& set1, vector<int>& set2) {
int distance = 0;
unsigned int i1 = 0;
unsigned int i2 = 0;
while(i1 < set1.size() && i2 < set2.size()) {
if(set1[i1] == set2[i2]) {
++i1; ++i2;
} else {...
Hi,
I written an exception handler routine that helps us catch problems with our software. I use
SetUnhandledExceptionFilter();
to catch any uncaught exceptions, and it works very well.
However my handler pop's up a dialog asking the user to detail what they were doing at the time of the crash. This is where the problem comes, becau...
I have a piece of code which compiles without problems with x86 gcc 4.4.1 but fails with blackfin gcc 4.1.2 with many "expected unqualified-id before numeric constant" errors. I see that there are some variable names that clash with some predefined macros. Is it possible to see defined macros at a certain line of a cpp file?
...