Hello everybody,
I would like to know the best solution in terms of performances for storing vectors/arrays of data (int or double), whose dimension is not available at compile time (it depends on the input from the user) but, once intialized, they will never change their dimensions, neither their values. In other words I was wondering ...
In cpp file I have std::round(double)
Please can I know the equivalent code in Java
Edit: I am already using java.lang.Math.round(double) and getting match in 99% cases. But in some places iam getting mismatch. For example:
std::round(4816.5058) = 4816 and Math.round(4816.5058) = 4817
std::round(4466.49996) = 4467 and Math.round(4466...
I'm trying to get a 64bit OpenGL application running with MESA compiled in 64 bit.
When compiling both in 32bit it works perfect putting the opengl32.dll and talloc.dll in the same directory as the executable, however, in 64bit the mesa opengl32.dll driver seems to simply pass on the my hardware driver.
If I change the opengl32.dll to a...
I'm coming from a background whereby pointers should generally be compared with 'NULL' and integers with '0'.
Since I didn't perceive Windows handles to be 'pointers' in the pure sense (being 'handles'), I'd got into the habit of comparing them with 0 rather than 'NULL'.
Clearly they're implemented internally as pointers nowadays, but ...
HI friends , Any one help me
The Important Difference: Overloading vs. Specialization in C++
It's important to make sure we have the terms with proof .Thanks in advance
The doubt arised "Why Not Specialize Function Templates?"
...
I want to ask you for your best practices regarding constructors in C++. I am not quite sure what I should do in a constructor and what not.
Should I only use it for attribute initializations, calling parent constructors etc.?
Or might I even put more complex functions into them like reading and parsing configuration data, setting up ex...
I wrote a test program like this:
#include <sys/socket.h>
int main( void ) {
int sock = socket(AF_INET, SOCK_DGRAM, 0);
return 0;
}
And tried to compile it:
$ /tool/sunstudio/bin/cc test.c
Undefined first referenced
symbol in file
socket test.o
l...
I maybe asking a dumb question, but I looked at the wikipedia page for RVO here and could not stop wondering if that behavior is wrong. I tried it in my machine and RVO is fully kicked in despite optimization level. What if there was actually something BIG happenning in a constructor? I know it shouldn't, but what if? I can't understand ...
Anyone knows such a tool?
...
Hi,
I'm trying to wrap a C++ library which uses auto_ptr. I'm using swig
and want to generate python bindings. I'v seen the section of the swig docu on how to use swig with smart pointers here[0]. But I can't get it to work.
swig generates code that wants to initialize the auto_ptr using a const
reference, but auto_ptr defines the cop...
Is it a good idea to return an iterator on a list in an object that is used and shared in a multi threaded environment?
class RequestList
{
public:
RequestList::RequestList();
RequestList::~RequestList();
std::list<boost::shared_ptr<Request> >::iterator GetIterator();
int ListSize();
void AddItem(boost::shared_ptr<R...
struct T
{
int a;
int b;
};
class Ptr
{
public:
Ptr(int a, int b) { t_.a = a; t_.b = b; }
T* operator->() {return &t_;}
T& operator*() {return t_;}
private:
T t_;
};
int main()
{
Ptr ptr(1, 2);
cout << "a = " << ptr->a << " b = " << ptr->b << endl;
cout << "a = " ...
i want to find address of elements of structure in memory
here is my code
#include <iostream>
using namespace std;
struct B{
int k;
float t;
char s;
unsigned int m;
long q;
double x;
unsigned long z;
};
int main(){
B b[]={3,4.23,'A',123,123L,23.340,700};
void *t=&b[0];
void *n=&b[0]+7;
while(t!=n){
...
Let me explain it with an example:
I have a class S, which is static.
I have two dynamic libraries A and B that use S.
I have an application, that links with A and B, in this application, how many different instances of S are created?
All this using C++ and in Ubuntu.
Thanks in advance
...
Hi, I read below statements in Addison Wesley FAQs.
Beware: passing objects by value can
be dangerous in some situations. Often
it is better to pass objects by
reference-to-const than to pass them
by value. For example, pass-by-value
won't work if the destination type is
an abstract base class and can result
in erron...
As I clould not pass LPCSTR from one function to another (Data get changed) I tried passing it as a string.
But later I need to again convert it back to LPSTR. While trying the conversion I am getting the above error:
cannot convert from 'std::string' to 'LPSTR'
How can I resolve this?
...
This seems to be giving me a bit of trouble. This method is supposed to generate a random number and assigns it to a char. getline grabs the entire string from the text file and assigns it to foods.
y has the purpose of holding the place of where it finds c in the foods string. It will then use that int to erase from the string and prin...
I am writing an application that needs to handle events fired by Office - things like 'before print' or 'new file'.
From various articles and examples I understand I should use the IConnectionPoint interfaces.
I got the ConnectionPointContainer for Word.Application using QueryInterface.
Now I want to run FindConnectionPoint, but I have ...
Anyone know of a tool that can find non-virtual destructors of polymorphic base classes?
...