c++

c++ constructors

suppose that MyClass has methods with the following prototypes: void method1(MyClass & object1);  MyClass * method 7();  What will be this method destructor, constructor, copy constructor, overloaded= or default constructor? This is one of question in my homework. I think the first one is default constructor and second one is copy...

pointer to function

Hi , i have template class that I did , and i want to do pointer to function: #ifndef __DATABASE_H_ #define __DATABASE_H_ #pragma once #include "Heap.h" #include <string> #include <map> #include <iostream> using namespace std; template<class S,class T> class Database { public: bool IsEmpty() const { return (m_map.size() == 0); }...

null terminator gives trouble with string length when comparing

I'm trying to compare 2 strings by "==" operator. when i print the string both are identical. but length of one is bigger by one, i figured it is the null terminator. any way to ignore this when comparing?? Thanks!! City* Adjutancy::FromStringToCity(string cityName) const { for (list<City*>::const_iterator it=m_citiesList.begin();it...

Template programming in C++

Hi, I am having trouble getting to grips with programming using templates in C++. Consider the following files. C.h #ifndef _C_H #define _C_H template <class T> class C { public: C(); virtual ~C(); } #endif _C_H C.cpp #include "C.h" template <class T> C<T>::C() { } template <class T> C<T>::~C() { } I try instantia...

Can I call select on a datagram socket without using blocking I/O

Can I call select before recv_from on a socket that is blocking? ...

returning an iterator

How i return iterator form function : i worte this : . .. template<class S,class T> class Database { public: . .. map<S,Node<T>*> m_map::iterator Find (S keyToFind); . .. .... private: . .. map<S,Node<T>*> m_map; .. . }; . .. template<class S,class T> map<S,Node<T>*> m_map::iterator Find (S keyToFind) { map<S,Node<T>*>::iterator ...

how to use Dijkstra c++ code using array based version

I need to use (not implement) an array based version of Dijkstras algo .The task is that given a set of line segments(obstacles) and start/end points I have to find and draw the shortest path from start/end point.I have done the calculating part etc..but dont know how to use dijkstras with my code.My code is as follows class Point { pub...

Creating Timers in C++ using Lua

I was wondering whether the following setup would work for a small game: Lets assume I have the following functions registered to Lua like so: lua_register(L, "createTimer", createTimer); lua_register(L, "getCondition", getCondition); lua_register(L, "setAction", setAction); Where: (leaving the type checking behind) int createTimer(...

How to cut off leading digits? C++

How can I cut off the leading digits of a number in order to only display the last two digits, without using the library. For example: 1923 to 23 2001 to 01 1234 to 34 123 to 23 with only #include <iomanip> #include <iostream> Thanks! ...

Using C++ for backend calculations in a web app

I'm running a PHP front end to an application that does a lot of work with data and uses Cassandra as a data store. However I know PHP will not give me the performance I need for some of the calculations (as well as the management for the sheer amount of data that needs to be in memory) I'd like to write the backed stuff in C++ and ac...

Template programming - Common Mistakes

Possible Duplicate: C++ template gotchas Hi, I am just in to my second month on SO, and I have seen enough number of posts on SO related to several common issues with templates. Is it a good idea to make a small Wiki on this (sadly I don't know how to make one)? The idea is to provide a reference as definitive as this (GMan'...

Boost GIL image constructors

Hi guys, I'm currently trying to figure out how to use the Generic Image Library included in Boost. Right now, I just want to use the library to store pixel data and use the Image IO to write PNGs. I'm having trouble understanding just how to set up the object however. The hpp says image(const point_t& dimensions, std::size_t al...

When do I need the Windows SDK and what is .NET for?

I am a student and after taking some introductory programming courses in Java, C, and just finishing up a book on C++, I would like to start developing applications for Windows. I have done my best to page through google and find the answers I need, but I seem to be at a loss. When would I need the Windows SDK over just the regular API...

Casting void *user_data to object

how do I cast void *something to an object in standard C++? Specifically I want want to cast void *userdata to std::map<String, void*> Is this possible? I am trying: //void *user_data is a parameter of this function (callback) std::map <String, void*> user_data_n; //this line is ok user_data_n = static_cast<std::map<String, void *>>(*u...

Overriding a default option(...) value in CMake from a parent CMakeLists.txt

I am trying to include several third-party libraries in my source tree with minimal changes to their build system for ease of upgrading. They all use CMake, as do I, so in my own CMakeLists.txt I can use add_subdirectory(extern/foo) for libfoo. But the foo CMakeLists.txt compiles a test harness, builds documentation, a shared library wh...

Disabling Bluetooth support in Windows XP-7

Hi I'm trying to write a program to disable the Bluetooth service on computers (so, forbid users from connecting to Internet via Bluetooth) I've tried following methods: Disable the "bthserv" service (Bluetooth Support Service). It works on Windows Vista and 7, but there is no such service in Windows XP (I haven't tested, but I think ...

EXEC_BAD_ADDRESS

Hi, maybe this is the continuation of this thread, The program compiles without errors or warnings but when I run it, and the handler function is called, I get EXEC_BAD_ADDRESS void MainController::show_color_trackbars(int *h, int *s, int *v){ String winName = "HSV Trackbars"; namedWindow(winName, CV_WINDOW_AUTOSIZE); std:...

SSDP Get Shared folder list using M-SEARCH?

hi , I am using SSDP to send discover request using M-SEARCH to get list of services present. My requirement is like i want to get list of share folders also which are present in that server. Currently , i am sending this request in this format : "M-SEARCH * HTTP/1.1\r\n" "Host: 239.255.255.250:1900\r\n" "Man: \"ssdp:discover...

Is if ( double\float(x) ) valid C++ code?

I just ran into this line of code; if( lineDirection.length2() ){...} where length2 returns a double. It kind of puzzles me that 0.0 in this case is equivalent to 0\NULL. Is this part of the C++ standard or is it undefined behaviour? ...

OS X 10.6.4 + Eclipse 3.5 + latest CDT not outputting cout/printf to console.

I spend most of my time in Eclipse these days, so I thought I would check out what Eclipse's C++ support was like (I usually use Xcode on Mac and Visual Studio for Windows). I found the CDT package for Eclipse 3.5, so I installed it. Everything installed properly and the default C++ "Hello World" project compiled nicely, however for th...