Without:
ATL
MFC
Note:
Plain C++
Out-of-process COM Object/server
Predefined TLB file
Question:
How to implement an outgoing interface, so the COM Object can notify the sink of events?
How to handle the event appropriately, once received?
Below is the event function I'd like to implement - from TLB file:
inline HRESULT IS8...
I have a predefined TLB file, with IS8SimulationEvents wrapper method implementations, for instance:
inline HRESULT IS8SimulationEvents::S8SimulationReset ( ) {
HRESULT _result = 0;
_com_dispatch_method(this, 0x1, DISPATCH_METHOD, VT_ERROR, (void*)&_result, NULL);
return _result;
}
Using Oleview, I can see the IConnectionP...
Hi all,
I'm looking for a C++ container class, that's a lot like a multimap, but slightly different. The container would store pairs of strings. But when I retrieve items from the container using key K, I want to find all the items where K begins with the item's own key.
E.G. If I use key "abcde" I want to find items with key "adc" ...
$ cat t.cpp
int sign(int i) {
if(i > 0) return 1;
if(i == 0) return 0;
if(i < 0) return -1;
}
$ g++ -c t.cpp -Wall
t.cpp: In function ‘int sign(int)’:
t.cpp:5: warning: control reaches end of non-void function
$
What do I do about this?
Stop using -Wall as it's clearly wrong? Add a bogus return 0 at the end? Clutter the co...
Without:
MFC
ATL
How can I use FormatMessage() to get the error text for a HRESULT?
HRESULT hresult = application.CreateInstance("Excel.Application");
if (FAILED(hresult))
{
// what should i put here to obtain a human-readable
// description of the error?
exit (hresult);
}
...
Hi, I've this sample program of a step that I want to implement on my application. I want to push_back the int elements on the string separately, into a vector. How can I?
#include <iostream>
#include <sstream>
#include <vector>
using namespace std;
int main(){
string line = "1 2 3 4 5"; //includes spaces
stringstream lineS...
Hi, as a novice C++ programmer there are some constructs that look still very obscure to me, one of these is const. You can use it in so many places and with so many different effects that is nearly impossible for a beginner to come out alive. Will some C++ guru explain once forever the various uses and whether and/or why not to use them...
I loved the Head First series book on object oriented design. It was a very gentle and funny introduction to the subject. I am currently taking a data structures class and find the text we are using (Kruse/Ryba Data Structures and Program Design in C++) to be very dry and hard to comprehend. This is mostly due I think to my own limita...
It seems COM objects are general use objects which are governed by the OS. The objects follow a strict interface and allow you to query the objects to determine information. Is this what COM objects are?
...
Without:
MFC
ATL
using COM, with pure C++, steps taken thus far:
//steps above omitted
_ApplicationPtr application(__uuidof(Excel::Application));
//omitted
const BSTR wcharFileName = SysAllocString(L"...");
application->Workbooks->Open(wcharFileName);
application->put_Visible(10, true);
Question:
How to then copy a cell, fo...
I can't decide whether I need or need not to buy Andrew Koenig book "Accelerated C++".
I do not think I am a beginner, but trying to reach the level I can use boost and STL in my projects.
What would you advise?
...
I am using an application in c++ that uses a special dprintf function to print information, this is an example:
dprintf(verbose, "The value is: %d", i);
What is doing is when I define verbose for test purposes then I print the information and when I am working in normal execution I do not define it and I do not see useless information...
If you code in C and configure your compiler to insist that all functions are declared before they are used (or if you code in C++), then you can end up with one of (at least) two organizations for your source files.
Either:
Headers
Forward declarations of (static) functions in this file
External functions (primary entry points)
Stati...
How can I validate the user input by using scanf. Right now I have something like this, but doesn't work.
NOTE: I have the atoi just to validate that the scanf validation works.
scanf("%[0987654321.-]s",buf);
i = atoi(buf);
if(i)
index = i;
...
In C++ the following code gives a compiler error:
void destruct1 (int * item)
{
item->~int();
}
This code is nearly the same, I just typedef the int to another type and something magic happends:
typedef int myint;
void destruct2 (myint * item)
{
item->~myint();
}
Why does the second code works? Does an int gets a destructor ju...
What are the best practices for choosing the linking method in VC++? Can anything/everything be statically linked?
On a dynamically linked project, is the relative/absolute location of the linked library important?
What are the pros and cons ?
added: I was mainly referring to lib files. Do they behave same as dll linking?
...
I want to make the line marked with // THIS LINE SHOULD BE PRINTING do its thing, which is print the int values between "synonyms" and "antonyms".
This is the text file:
dictionary.txt
1 cute
2 hello
3 ugly
4 easy
5 difficult
6 tired
7 beautiful
synonyms
1 7
7 1
antonyms
1 3
3 1 7
4 5
5 4
7 3
#include <iostream>
#include <fstrea...
I want to eliminate the junk that I'm getting on the vector<int> synsAux below. It should print:
1
7
7
1
I'm getting an extra 2 before the first and third digit, why? Is this 2 an ascii value for the blank space or something? How do I avoid its reading?
This is the dictionary file needed to run the program:
dictionary.txt
1 cute
2 ...
I need to add the "Run when Windows starts" option to my program CintaNotes, but do not want to sacrifice the "cleanness" of it: it is a 100% portable freeware and should not leave traces in the system.
I've come up with the idea to autodetect running from the Startup shortcut and automatically minimizing to the system tray. Is there a w...
When I write C++ code for a class using templates and split the code between a source (CPP) file and a header (H) file, I get a whole lot of "unresolved external symbol" errors when it comes to linking the final executible, despite the object file being correctly built and included in the linking. What's happening here, and how can I fi...