|
I tried to use the boost::any but i have to use linux to do the program and it sent me back a million error messages when i tried to compile it.
as for the struct i wish it was that easy. my problem is not knowing how many members there would be in the struct. the sample file i'm working with has those title, price, and in stock fields but for other files there could be more or less fields. if a struct was like a vector then i could declare it and then later just add the members when i know the fields.
i think i might just have to treat all the fields as strings and then create a vector to store them in...
thanks for your help though!
|
|
|
|
|
Maybe you need to have those fields available in the struct, but default them to something like -1 when not in use. If it's something that may have multiple definitions, like the price, use vectors for that as well. Example:
struct ItemDefinition
{
CString title;
int itemNumber;
double prices;
int isInStock;
vector<double> taxRates;
vector<CString> descriptions;
};
Maybe this would help?
modified on Saturday, October 24, 2009 3:17 PM
|
|
|
|
|
rhenry84 wrote: I tried to use the boost::any but i have to use linux to do the program and it sent me back a million error messages when i tried to compile it.
Linux is no hindrance to using boost::any - most of Boost is developed on Linux, I suspect.
As for your real problem - what I would probably do is use a std::map<string, string> for each record, mapping field name to field value (as a string).
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
|
As I can see from the screen-shot, your project is in Release mode.
Why you are debugging your application in Release mode?
Did you try to use the Watch window in Debug mode?
Nuri Ismail
|
|
|
|
|
AHHH, how can ??? Thank you very much. You saved me. I think i should go to bed soon. Cannot work with this mood now
|
|
|
|
|
Then I wish you Bug-Free dreams!
Nuri Ismail
|
|
|
|
|
What is abstract class?I feel difficult to understand that concept.Can any one explain with example? and also give me the difference between ordinary class and abstract class...
|
|
|
|
|
|
Vinoli wrote: What is abstract class?I feel difficult to understand that concept.Can any one explain with example?
Here[^] you will find an explanation of this concept with examples. Also the article shows the differences between ordinary classes and abstract classes.
If you have some questions after reading the article, feel free to ask.
I hope this helps.
Nuri Ismail
|
|
|
|
|
An abstract class is one that you cannot instantiate.
The class A is abstract because One() has not been defined.
class A
{
public:
void One() = 0;
};
The class B is not abstract since Two() has been defined and so can be instantiated.
class B
{
public:
void Two() {}
};
The class C also becomes abstract since it inherits One() from class A , but it is still not defined.
class C : public A
{
public:
void Three() {}
};
The class D is not abstract and can be instantiated since it inherits One() from class A and then defines it.
class D : public A
{
public:
void Four() {}
void One() {}
};
|
|
|
|
|
An abstract C++ class is an interface.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
Hi. Well.. I am developing a little game and a have this trouble. I want to make the window scroll by clicking and draging. It already works and works fine. But... My map is made of buttons and when i try to move the window by clicking and draging at the buttons positions main window doesn't recive ON_WM_MOUSEMOVE signal. So how can i make my application to generate ON_WM_MOUSEMOVE when i am clicking buttons? Tnx for help.
|
|
|
|
|
When the left mouse button is pressed on a button, the expected behavior is a button click.
Do you not want that behavior?
Is the button not click-able?
If yes, then how do you want it to scroll?
|
|
|
|
|
Well. Button is clickable, but i want that my main window recive message wm_mousemove instead of button. I solved it a little while ago with
void MPictureBox::OnMouseMove(UINT nFlags, CPoint point)
{
CRect pRect;
CPoint cp;
GetCursorPos(&cp);
this->GetParent()->ScreenToClient(&cp);
LPARAM lParam = ((cp.y) << 16) + cp.x;
this->GetParent()->PostMessageA(WM_MOUSEMOVE,nFlags,lParam);
}
But anyway thanks =)
|
|
|
|
|
I have class A and class B:
template<typename T>
struct A
{
T data;
...
};
template<typename T>
struct B
{
T data;
...
};
I can do the following:
B<A<int> > b1;
B<A<MyOtherType> > b2;
But, these lines are so ugly and I want to make special type. I want to have something like this:
myBA<int> b1;
myBA<MyOtherType> b2;
How I can do it ?
or where I can read about templates like these ?
|
|
|
|
|
template<typename T>
struct myBA : public B< A<T> >
{
};
...cmk
The idea that I can be presented with a problem, set out to logically solve it with the tools at hand, and wind up with a program that could not be legally used because someone else followed the same logical steps some years ago and filed for a patent on it is horrifying.
- John Carmack
|
|
|
|
|
Yes, I know that approach. But I wanna have another way, without declaration of new class.
|
|
|
|
|
You can write it as one line of code, do you expect to find something shorter ?
What's wrong with declaring a new class?
That's what you asked for.
...cmk
The idea that I can be presented with a problem, set out to logically solve it with the tools at hand, and wind up with a program that could not be legally used because someone else followed the same logical steps some years ago and filed for a patent on it is horrifying.
- John Carmack
|
|
|
|
|
Thanks.
Could you recommend me any books when there is detailed descriptions of these questions ?
|
|
|
|
|
|
Here is one way to do it.
typedef A<int> IntA;
typedef A<MyOtherType> MyOtherInt;
B<IntA> b1;
B<MyOtherInt> b2;
Or you could go one step further.
typedef A<int> IntA;
typedef A<MyOtherType> MyOtherInt;
typedef B<IntA> myIntBA;
typedef B<MyOtherInt> myOtherBA;
myIntBA b1;
myOtherBA b2;
You could also make the above into a single typedef.
typedef B<A<int>> myIntBA;
typedef B<A<MyOtherType>> myOtherBA;
myIntBA b1;
myOtherBA b2;
|
|
|
|
|
Hi
Can i get image morphing source code ,written with visual c++ 2008 ,from dog to cat or something like that...
Regards
fpehpeh
|
|
|
|
|
I assume you checked with google before ? there are couple of hits with source code, maybe not c++/vs2008, but nothing preventing you to look at them and convert them.
anyway, good luck.
This signature was proudly tested on animals.
|
|
|
|
|
hi,
I need to convert outlook contact information into a text file or a rtf format. Please if any one knows any references related to this send me..
Thanx in advance
sampath-padamatinti
|
|
|
|