I am trying to return a new copy of the data in a C++ Template class. The following code is getting this error: invalid conversion from ‘int*’ to ‘int’. If I remove the new T then I am not returning a copy of the data but a pointer to it.
template<class T>
T OrderedList<T>::get( int k )
{
Node<T>* n = list;
for( int i = ...
I'm using VS2008, my OS is Win7.
I tried WinAPI IOCTL_VIDEO_QUERY_SUPPORTED_BRIGHTNESS on my netbook. I can retrive a correct the LCD handle, but DeviceIoControl returns 0. I haven't found any APIs for GMA 3150 either.
...
File a.hpp:
class a;
typedef boost::shared_ptr<a> aPtr
class a{
public:
static aPtr CreateImp();
virtual void Foo() = 0 ;
....
};
File aImp.hpp:
class aImp : public a{
virtual void Foo();
};
File aImp.cpp:
aPtr a::CreateImp()
{
return aPtr(new aImp());
}
void aImp::Foo(){}
The client must use CreateImp t...
I have some questions about vector in STL to clarify.....
Where are the objects in vector allocated? heap?
does vector have boundary check? If the index out of the boundary, what error will happen?
Why array is faster than vector?
Is there any case in which vector is not applicable but array is a must?
...
HI I am starting to learn openGl for C++.but at stating point I stucked.
I have 2 question that is the coordinates for drawing some objects? I mean where is X, Y and Z?
Second one I am making tutorial from some sites. and I am trying to animate my triangle.In tutorial it works but on my computer not.I Also downloaded source codes b...
I am curious? What high fundu logic goes behind not implementing:
result+=vector1;
where both result and vector1 are stl vectors.
Note: i know how to implement that bit, but i need to know what logic, the sages who designed STL were using when they chose not to implement this feature?
...
Hi,
Is it recommended to use cstdio,cstring,cmath in c++?
I was writing a program that needed pow , strlen and sprintf ... for that the only way I could do it was to include these 3 headers. Is there a better C++ way to do it?
Thanks
...
I have some numbers stored in a vector . I want to find which number appears most in the vector.
Is there any easy/fast algorithm (STL or whatever) that does this ?
...
I have the following code:
#include <boost/shared_ptr.hpp>
struct Foo { int a; };
static int A;
void
func_shared(const boost::shared_ptr<Foo> &foo) {
A = foo->a;
}
void
func_raw(Foo * const foo) {
A = foo->a;
}
I thought the compiler would create identical code, but for shared_ptr version an extra seemingly redundant instru...
Hello everyone :)
I've got a series of filepaths that look something like this:
C:\Windows\System32\svchost.exe -k LocalSystemNetworkRestricted
C:\Windows\System32\svchost
C:\Program Files (x86)\Common Files\Steam\SteamService.exe /RunAsService
"C:\Program Files (x86)\Common Files\Steam\SteamService.exe" /RunAsService
and I need to ...
After reading this question, i saw the answer by Naveen containing a link to this page, which basically says, that casting from Derived** to Base** is forbidden since could change a pointer to an pointer to a Derived1 object point to a pointer to a Derived2 object (like: *derived1PtrPtr=derived2Ptr).
OK, i understand this is evil ...
B...
I can't get past this issue I am having. Here's a simple example:
class x
{
public:
void function(void);
private:
static void function2(void);
};
void x::function(void)
{
x::function2(void);
}
static void function2(void)
{
//something
}
I get errors in which complain about function2 being private. If I make it...
Hi,
I have got this code and I am trying to understand the convention followed, all the method defined in the .cpp file have template<class KeyType, class DataType> written before them. What does that mean?
Example:
//Constructor
template<class key, class type>
MyOperation<key, type>::MyOperation()
{
//method implementation
}
//A m...
My problem is that I'm having trouble specifying paths for Lua to look in.
For example, in my script I have a require("someScript") line that works perfectly (it is able to use functions from someScript when the script is run standalone.
However, when I run my app, the script fails. I believe this is because Lua is looking in a locati...
I'm writing a GUI app with wxwidgets in C++ for one of my programming classes. We have to validate input and throw custom exceptions if it doesn't meet certain conditions. My question is, what is best practice when it comes to this? Should I write a seperate function that checks for errors, and have my event handler's call that function?...
Hi,Our barcode scanner application is written in C++ eMbedded V 4.00 and works well on the Motorola MC50 WM5 where the ENTER key is interpreted as an IDOK. We are moving the app to the MC55 with WM6.1 and the ENTER key does not translate to an IDOK. I'm of the impression we will have to programatically trap the key entry (or the value ...
I'd like to manage a bunch of objects of classes derived from a shared interface class in a common container.
To illustrate the problem, let's say I'm building a game which will contain different actors. Let's call the interface IActor and derive Enemy and Civilian from it.
Now, the idea is to have my game main loop be able to do thi...
I am adding some code to an existing FreeBSD device driver and I am trying to pass a char* from user space to the driver. I've implemented a custom ioctl() command using the _IOW macro like so: #define TIBLOOMFILTER _IOW(0,253,char*)
My call looks something like this:
int file_desc = open("/dev/ti0", O_RDWR);
ioctl(file_desc, TIBLOOMF...
I am programming in c++ MFC,
I want to get "C:\windows" "c:\program files" folder path.
Sometimes user may setup windows in other folder such as c:\windows0.
Is there any API to get absolute path of the windows and program files path?
Many thanks!
...
Hi,
Is there a way to set the "minimum" number of decimal places that a std::ostream will output?
For example, say I have two unknown double variables that I want to print (values added here for the sake of illustration):
double a = 0;
double b = 0.123456789;
I can set my maximum decimal precision so that I output b exactly
std::c...