I have a map (enum, vector< double >) in c++ code that I want to access from a c# application. This is legacy code, so I'm limited to using COM objects to pass information. Currently we pass in one enum at a time to c++, and get back one vector at a time as a SAFEARRAY.
I tried passing in a SAFEARRAY of enums, and returning a SAFEARRAY...
Hi!
I have written some classes, the back end of a project in C++ (win32 project) and then wanted to add a GUI to it. Visual C++ seemed to be a good solution but after having the GUI part done I couldn't integrate the plain C++ code. Does someone have any experience with that? I get 'unresolved externals' error. Apperantly the .cpp file...
Is there a way to find out the number of digits of min/max values of an integral type at compile time so that it's suitable to be placed as a template parameter?
Ideally, there will be an existing solution in, for example, Boost MPL. Failing that I'm looking for some pointers for a hand-coded solution.
...
I am trying to find an author in a set, and i am having problems doing so.
in the library.cpp is where i am adding the information from main()
#include "Library.h"
#include "book.h"
#include "cd.h"
#include "dvd.h"
#include <iostream>
// general functions
ItemSet allBooks;
ItemSet allCDS;
ItemSet allDVDs;
ItemSetMap allBooksByAu...
I have a simple managed C++ assembly which I am providing unmanaged wrappers for some static methods I have in a C# assembly. One of these methods returns a string which I have converted to a "const char*" type in the C++ assembly. The trouble I am having is that when I load this dll from an unmanaged source, I get bad data back in the p...
I can't use "long long"; what should I be using?
...
Hi,
In C/C++, there is a 'write() function which let me write to either file or a socket, I just pass in the file descriptor accordingly). And there is a fprintf() which allow me to do fprintf (myFile, "hello %d", name); but it only works for file.
Is there any api which allows me to do both?
i.e. able to let me do print formatting an...
Suppose in one program, I'm given:
class Foo {
int x;
double y;
char z;
};
class Bar {
Foo f1;
int t;
Foo f2;
};
int main() {
Bar b;
bar.f1.z = 'h';
bar.f2.z = 'w';
... some crap setting value of b;
FILE *f = fopen("dump", "wb"); // c-style file
fwrite(&b, sizeof(Bar), 1, f);
}
Suppose in another program, I h...
My function takes an array of ifstream ofjects and the number of ifstream objects as seen below:
void MergeAndDisplay(ifstream files[], size_t count)
My problem is I want to use a while loop to read from the file(s) as long as one of them is open. When I get to eof, I close the file. So I thought I could do something like
int fileN...
Hello,
If I have the following files, I get this error (c2593 in VC9).
If I un-comment the prototype in main.cpp, the error disappears. I need to maintain the same functionality while keeping the class out of main.cpp. How can I do that?
Thanks.
main.cpp:
#include "number.h"
//const Number operator + (const Number & lhs, const Numbe...
I'm writing a GLFW app in C++ on MacOSX.
It runs in GLFW_FULLSCREEN mode
Now, when I press the "dim screen / f1" button, my Mac dims my screen.
I do not want that to happen. Instead, I want GLFW to receive a "key press F1" event (or a "key press blah blah blah" event. Is there a way to tell MacOSX to NOT interpret the "dim screen" and...
I was looking at the various windows styles flags, and I noticed that a few flags are defined as such:
#define WS_TILED WS_OVERLAPPED
#define WS_ICONIC WS_MINIMIZE
#define WS_SIZEBOX WS_THICKFRAME
#define WS_TILEDWINDOW WS_OVERLAPPEDWINDOW
What is the purpose of defining new flags that are literally ...
I have a solution created using visual studio 2008 named, "Solution", and i have two projects in that solution, project "A" and project "B". when i do a thing like below it shows fatal errors in the bottom. I have given in project A->properties->Additional include Directries as ../B
project B
B.h
#include <iostream>
using namespace s...
In the following code
#include<iostream>
template<typename T,size_t N>
void cal_size(T (&a)[N])
{
std::cout<<"size of array is: "<<N<<std::endl;
}
int main()
{
int a[]={1,2,3,4,5,6};
int b[]={1};
cal_size(a);
cal_size(b);
}
As expected the size of both the arrays gets printed. But how does N automa...
std::vector<Foo> vec;
Foo foo(...);
assert(vec.size() == 0);
vec.reserve(100); // I've reserved 100 elems
vec[50] = foo; // but I haven't initialized any of them
// so am I assigning into uninitialized memory?
Is the above code safe?
...
Does your editor/ide highlight that a++; in this C/C++ code as part of a comment?
int a=1;
//some comment \
a++;
printf("%d\n",a);
And what about this?
int a=1;
//some comment ??/
a++;
printf("%d\n",a);
...
With stl::vector:
vector<int> v(1);
v[0]=1; // No bounds checking
v.at(0)=1; // Bounds checking
Is there a way to disable bounds checking without having to rewrite all at() as []? I am using the GNU Standard C++ Library.
Edit: I changed at() to [] in the area where I suspected a bottleneck, and it significantly reduced the computatio...
Hi,
I have a class which has a private attribute which is a reference to another class:
class A {
public:
A();
A(B& anotherB);
private:
B& bRef;
}
In my A(B& anotherB), I can do this:
A::A(B& anotherB)
: bRef(anotherB) {
}
But what about A()? I tried this:
A::A()
: bRef(B()) {}
But I get this error 'error:...
I am currently implementing a basic raytracer in c++. Works pretty well so far, matte materials (with ambient and diffuse brdf) work as expected so far.
Adding specular highlights would result in the full Phong Model and that's exactly what i tried to do.
Unfortunately, i encounter gamut overflow, with all kinds of values for the specu...
Hi all,
I've just come across the following code:
#include <iostream>
static class Foo
{
public:
Foo()
{
std::cout << "HELLO" << std::endl;
}
void foo()
{
std::cout << "in foo" << std::endl;
}
}
blah;
int main()
{
std::cout << "exiting" << std::endl;
blah.foo();
return 0;
}
...