|
Since we're on a more Microsoft centric webbie, I could suggest downloading the Visual Studio Express Edition.
Maybe you can use the VS compiler in NetBean.
Watched code never compiles.
|
|
|
|
|
Why not check this[^] out on the NetBeans site?
I must get a clever new signature for 2011.
|
|
|
|
|
Why, you can use loads of free C++ compilers!
There DJGPP (GNU suite) for Windows and Linux, Borland C++ for Windows. There is also an excellent compiler called TCC that can compile HUGE sources with lightning speed because it does not use intermediate assembly.
Search these names on any search engine and you will get the web-address! 
|
|
|
|
|
hello guys... I am trying to connect to database using ADO in MFC dialog based app. Now I get error at the first step when I try to create new connection and recordset using COM but I getting 4 errors stating "unresolved external symbol"
- "error LNK2001: unresolved external symbol _CLSID_CADORecordset"
- "error LNK2001: unresolved external symbol _IID_IADORecordset"
- "error LNK2001: unresolved external symbol _CLSID_CADOConnection"
- "error LNK2001: unresolved external symbol _IID_IADOConnection"
#include <adoid.h>;
#include <adoint.h>;
#include <comdef.h>;
CComPtr<ADORecordset> m_pSet;
CComPtr<ADOConnection> m_pConn;
::CoCreateInstance(CLSID_CADOConnection, NULL, CLSCTX_INPROC_SERVER, IID_IADOConnection, (LPVOID*) &m_pConn);
::CoCreateInstance(CLSID_CADORecordset, NULL, CLSCTX_INPROC_SERVER, IID_IADORecordset,(LPVOID *) &m_pSet);
Thats is what I was trying to do. What can be the reason?? thnx
|
|
|
|
|
According to this[^], it should be fixed if you include initguid.h before adoid.h.
modified 13-Sep-18 21:01pm.
|
|
|
|
|
thanx...it worked for me.
|
|
|
|
|
I use these[^] classes in order to use ADO in my MFC apps. Sure beats the heck out of reinventing the wheel yet again.
You may be right
I may be crazy
-- Billy Joel --
Within you lies the power for good - Use it!
|
|
|
|
|
i want to know what is ":" operator in C++ called. i know how it is used in access specifiers but i saw something new for me.
destructor.hpp
class A {
int i;
public:
A(); //
A(int a);//
~A(); //
};
destructor.cpp
#include "destructor.hpp"
#include <iostream>
using namespace std;
A::A() : i(0) // WHAT IS ": i(0)" ?, WHAT IS ":" MEAN HERE ?
{
cout << "default constructor of A" << endl;
}
A::A(int a) : i(a)
{
cout << "constructor of A(" << i << ")" << endl;
}
A::~A()
{
cout << "Destructor of A (i=" << i << ")" << endl;
}
|
|
|
|
|
This is just a shorthand way of initialising variables in the constructor, and is equivalent to coding:
A::A()
{
i = 0;
...
I must get a clever new signature for 2011.
|
|
|
|
|
ok, then what is going on here please?
class A {
public:
A() { cout << "(1)"; }
A(A &a) { cout << "(2)"; }
};
class B {
A a;
public:
B() : a() { cout << "(3)"; }
};
…
B b;
B b2(b);
|
|
|
|
|
It's initialising the object a of class A . In each case it is merely calling the object's constructor, and for primitive types (such as int ) that just means setting them to the value in parenthesis.
Take a look at your C++ notes or manual for further discussion of instantiation, inheritance etc.
I must get a clever new signature for 2011.
|
|
|
|
|
The : is called a colon by me - and many other people
It does different jobs in different places.
Ie:
switch (iValue)
{
case Bob:
goto finished;
....
finished:
return bIUseGotos;
}
bSuccess = (pFunction != NULL) ? pFunction->DoSomething () : false;
And in your case, I'll pick a more common example:
class A
{
public:
A (int i);
};
class B : public A
{
public:
A ();
}
Now we make a constructor...
B::B ()
{
}
This will not compile - you will get a complaint about A not getting having a constructor with no parameters.
So, we need:
B::B ()
: A (7)
{
}
The principle is exactly the same for member variables.
In your example, i's constructor is being called with 0. In the case of basic variables, there's an implicit constructor for this. It's not a real one.
As for what you'd call it, I have no idea. Inheritance operator?
Iain.
I am one of "those foreigners coming over here and stealing our jobs". Yay me!
|
|
|
|
|
In the case you're asking about the colon marks the start of an initialiser list. These describe how to initialise a class's base class or member variables. Each element of the initialiser list has the syntax:
A( x, ... )
where A is either the name of the base class or the name of the member variable to be initialised and x,... is the list of arguments to the constructor of the base class or member.
I'd suggest grabbing a copy of "The C++ Programming Language" by Bjarne Stroustrup. He describes the initialisation of member objects and base classes in loads of detail in part 2 of the book. And explains why you'd prefer to write initialisers rather than making assignments in the body of a constructor.
Cheers,
Ash
|
|
|
|
|
all i can recall is that the ":" is the resolution operator in c++ which basically mean that A() is a method in the A namespace
google it or buy yourself a good c++ book
|
|
|
|
|
How to get computer color setting,
such as 256 colors and 16 or 32 bits?
|
|
|
|
|
By using GetDeviceCaps(BITSPIXEL)
HDC hDC = GetDC(NULL);
int nBitsPerPixel = GetDeviceCaps(hDC , BITSPIXEL);
ReleaseDC(NULL, hDC );
|
|
|
|
|
Hi, thanks, it works well.
the color setting looks like independent from HDC, is there a HDC independent function to obtain the value?
|
|
|
|
|
|
Hi ...
Happy New Year. Hope everyone is ok. I have not been here for a while.
I have some contact lens data I'm trying to sort. I have some sort rules are static (hard-coded) followed by other rules form 'normal' rules
Here are the requirements:
1. First sort by Company and Product is a static order (hard-coded, non alphbetic)
Sample
o Company ProductName
--------------------------------------------------------------------
1. Ciba 1. Focus, 2. AirOptics, 3. Dailies, 4. then alphabetical.
2. Bausch & Lomb 1. PureVision, 2. LiquidEye, 3. Softlens then alphabetical.
2. Followed by Package size decending (80, 30 ...)
3. Followed by Base Curve decending (8.6, 8,0 ...)
4. Followed by Sphere decending (-0.5, 0.0, 1.0 ...)
In the end the result might look like the following
Sample data
CO PR PS BC Sp
-------------------------------
Ciba Focus 10 8.6 0.00
Ciba Focus 20 8.6 -0.25
Ciba Focus 20 8.6 -0.10
Ciba Focus 20 8.6 +0.25
Ciba Air 10 8.6 -0.25
Ciba Air 10 8.6 -0.10
Ciba Air 20 8.1 -0.25
Ciba Air 20 8.1 -0.10
Ciba Air 20 8.1 0.00
Ciba Air 20 8.6 +0.25
Ciba Air 20 8.6 +0.40
The data is contained in a struct with other data. The stuct is used in a map with a key. I am building a key to sort for the static requirments such as below.
The key contains a prefix at the front of the key to force the static sort (non alphabetical), followed by a suffix to make the key unique. Sample key: "1_1_Ciba_Focus Monthlys_4"
My plan to sort the other requirments is to take each of the other requirments (PackageSize, Base Curve and Sphere) and sort them against the previous element with the key.
Since I will be sorting the following agaist the Package Size (10, 20 ...) - maybe I should be using the multimap, as it might be easter to sort this stuff without having the unique ID at the end of key ??
With the key of "1_1_Ciba Focus" I would sort on the PackSize and then set the key to produce the correct sort
start: (std::multimap)
key: 1_1_Ciba Focus"
Sample data
CO PR Key
-------------------------------
Ciba Focus 1_1_Ciba Focus
Ciba Focus 1_1_Ciba Focus
Ciba Focus 1_1_Ciba Focus
Ciba Focus 1_1_Ciba Focus
Sample data
CO PR PS Key
-------------------------------
Ciba Focus 10 1_1_1_Ciba Focus
Ciba Focus 20 1_1_2_Ciba Focus
Ciba Focus 20 1_1_2_Ciba Focus
Ciba Focus 20 1_1_2_Ciba Focus
Thanks,
Chris
chris@macgowan.com
|
|
|
|
|
Maps are sorted by the key, so you cant have them stored in the static order for 1.
Depending on how often you are adding to the list and to where i would recomend either a std::vector or std::list for storing the data in the static order
Your question is a little unclear, but if i'm reading it correctly you need something like this.
cmacgowan wrote: 4. Followed by Sphere decending (-0.5, 0.0, 1.0 ...) The order there is ascending
#include <stdio.h>
#include <string>
#include <vector>
#include <map>
using std::string;
using std::map;
using std::vector;
class ProductTypeKey {
public:
ProductTypeKey() { }
ProductTypeKey(unsigned _nPackageSize, float _nBaseCurve, float _nSphere)
: nPackageSize(_nPackageSize), nBaseCurve(_nBaseCurve), nSphere(_nSphere) { }
public:
unsigned nPackageSize;
float nBaseCurve;
float nSphere;
};
typedef struct {
} ProductTypeData;
struct MyItemCompare {
bool operator()(const ProductTypeKey &mkLeft, const ProductTypeKey &mkRight) const {
if (mkLeft.nPackageSize != mkRight.nPackageSize) {
return mkLeft.nPackageSize > mkRight.nPackageSize;
}
if (mkLeft.nBaseCurve != mkRight.nBaseCurve) {
return mkLeft.nBaseCurve > mkRight.nBaseCurve;
}
if (mkLeft.nSphere != mkRight.nSphere) {
return mkLeft.nSphere < mkRight.nSphere;
}
return false;
}
};
class Product {
public:
typedef map<ProductTypeKey, ProductTypeData, MyItemCompare> TypesMap;
public:
Product() { }
Product(const string &_strCompany, const string &_strProduct)
: strCompany(_strCompany), strProduct(_strProduct) { }
void AddType(const ProductTypeKey &key, const ProductTypeData &data){
colTypes.insert(TypesMap::value_type(key, data));
}
public:
string strCompany;
string strProduct;
TypesMap colTypes;
};
int main(int argc, char *argv[]) {
Product prodCibaFocus("Ciba", "Focus");
prodCibaFocus.AddType(ProductTypeKey(10, 8.6f, +0.00f), ProductTypeData());
prodCibaFocus.AddType(ProductTypeKey(20, 8.6f, -0.25f), ProductTypeData());
prodCibaFocus.AddType(ProductTypeKey(20, 8.6f, -0.10f), ProductTypeData());
prodCibaFocus.AddType(ProductTypeKey(20, 8.6f, +0.25f), ProductTypeData());
Product prodCibaAir("Ciba", "Air");
vector<Product> colProducts;
colProducts.push_back(prodCibaFocus);
colProducts.push_back(prodCibaAir);
colProducts[1].AddType(ProductTypeKey(10, 8.6f, -0.25f), ProductTypeData());
colProducts[1].AddType(ProductTypeKey(10, 8.6f, -0.10f), ProductTypeData());
colProducts[1].AddType(ProductTypeKey(20, 8.1f, -0.25f), ProductTypeData());
colProducts[1].AddType(ProductTypeKey(20, 8.1f, -0.10f), ProductTypeData());
colProducts[1].AddType(ProductTypeKey(20, 8.1f, +0.00f), ProductTypeData());
colProducts[1].AddType(ProductTypeKey(20, 8.6f, +0.25f), ProductTypeData());
colProducts[1].AddType(ProductTypeKey(20, 8.6f, +0.40f), ProductTypeData());
for (vector<Product>::const_iterator iProduct = colProducts.begin(); iProduct != colProducts.end(); ++iProduct) {
for (Product::TypesMap::const_iterator iType = iProduct->colTypes.begin(); iType != iProduct->colTypes.end(); ++iType) {
printf("%s %s %u %.02f %.02f\n", iProduct->strCompany.c_str(), iProduct->strProduct.c_str(),
iType->first.nPackageSize, iType->first.nBaseCurve, iType->first.nSphere);
}
}
return 0;
}
|
|
|
|
|
Hi Andrew Brock,
Thanks for the response. I'll look at it and try it out.
Looks good.
I'll post a follow up.
Thanks,
Chris
|
|
|
|
|
I'm not 100% sure what you're driving at but it looks as if you only want to use a map so you can synthesise a key and then use that to control the sort. The traditional way (at least in C++) to force a sort order in a collection is to implement operator< for the key (in a map) or the value (in a vector) that you're storing.
So if you've got a class with your contact lens data in try something like:
class contact_lens_data
{
friend bool operator< (const contact_lens_data &left, const contact_lens_data &right );
};
bool operator< (const contact_lens_data &left, const contact_lens_data &right )
{
}
Then you can store them in any collection and get the collation order you want using std::sort or the inserter for std::map .
Cheers,
Ash
|
|
|
|
|
Thanks for the info
I'll check it out
Chris
|
|
|
|
|
Hello,
I was just wondering whether it was possible to connect two PCs with a USB cable and simulate a keyboard on one of them. I know I could do this with a client/server system using DirectInput, but would it still be possible without installing any software on the target machine? If possible I would like to avoid using any micro-controller between the to PCs.
Any ideas whether that's possible or not?
Ben
|
|
|
|
|
RedDragon2k wrote: without installing any software on the target machine
Obviously something must run to capture the input on the target machine and inject it into the OS. So presumably you just mean that you don't want to install it first.
Should be possible to get the USB itself to do it. You might start by looking into how one boots an OS from a memory stick. Such articles have detailed info on how USB works.
|
|
|
|
|