|
Why don't you try the bitset from STL[^]?
You can easely do the following things:
typedef std::bitset<8> Flag8;
typedef std::bitset<11> Flag11;
Behind every great black man...
... is the police. - Conspiracy brother
Blog[^]
|
|
|
|
|
Imagine the following situation:
class A<br />
{<br />
public:<br />
A(int x, int y) {...}<br />
};<br />
<br />
int func1()<br />
{<br />
return ...;
}<br />
<br />
int func2(int arg)<br />
{<br />
return arg / 2;
}
You can not change the above. But you need to inherit from A and you want to pass func1() as the first argument and func2 of the first argument as the second argument to the constructor of A:
class B : public A<br />
{<br />
public:<br />
B():A(func1(), func2())<br />
{<br />
} <br />
};
What do you think is the best way to do this? A possible solution is:
class B : public A<br />
{<br />
protected:<br />
B(int x, int y):A(x, y))<br />
{<br />
} <br />
<br />
public:<br />
static B create()<br />
{<br />
int f1 = func1();<br />
return B(f1, func2(f1));<br />
}<br />
};
However, this would obstruct future inheritance from B.
|
|
|
|
|
How about the following?
<br />
class A2 : public A<br />
{<br />
protected:<br />
A2(int arg) : A(arg, func2(arg))<br />
{<br />
}<br />
};<br />
<br />
class B : public A2<br />
{<br />
public:<br />
B() : A2(func1())<br />
{<br />
}<br />
};<br />
Another possibility:
<br />
class B : public A<br />
{<br />
public:<br />
B(int x, int y) : A(x,y)<br />
{<br />
}<br />
<br />
B()<br />
{<br />
int f1 = func1();<br />
B aux(f1, func2(f1));<br />
*this = aux;<br />
}<br />
};<br />
--
jlr
http://jlamas.blogspot.com/[^]
|
|
|
|
|
The first one is nice indeed.
|
|
|
|
|
Hi CPians,
I would like to change programmatically the version information of a file (e.r. the ones you get when you open the properties dialog of a file in the explorer). This is for adding revision information automatically.
I know how to access this data (GetFileVersionInfo ,GetFileVersionInfoSize and similar) but how can I modify it ?
Thanks,
~RaGE();
|
|
|
|
|
Use RT_VERSION with this.
"Ideas are a dime a dozen. People who put them into action are priceless." - Unknown
|
|
|
|
|
Thanks for the answer David, but this is only for Word documents, isn't it ? I was actually hoping to change the properties of any file (Word document, text file, ...).
~RaGE();
|
|
|
|
|
Rage wrote:
...but this is only for Word documents, isn't it ?
No, it works for others too.
"Ideas are a dime a dozen. People who put them into action are priceless." - Unknown
|
|
|
|
|
//header file
/////////////////////////////////////////////
node* next;
};
class cqueuetype
{
public:
cqueuetype();
void EnqueueRear(node* newNode);
void display();
bool isempty();
void makeEmpty();
void save();
void load();
void find();
void find1();
char infile();
void num_of_memo();
private:
node* rear;
node* front;
int counter;
};
//////////////////////////////////////////////
//Part of da cpp
//////////////////////////////////////////////
void cqueuetype::save()
{
node* saving=front;
ofstream outfile("c:\\queue.txt",ios::out);
if(!outfile)
{
cout<<"Can not find drive"<<endl;
}
="" else
="" {
="" outfile<<counter<<endl;
=""
="" while="" (saving="" !="NULL)
" outfile<<"title:"<<endl;
="" outfile<<"="" "<<saving-="">Title<<endl;;
outfile<<"date="" &="" time:"<<endl;
="" outfile<<"="" "<<saving-="">Date_Time<<endl;
outfile<<"memo:"<<endl;
="" outfile<<"="" "<<saving-="">Content<<endl;
outfile<<"....................................."<<endl;
="" saving="saving-">next;
}
outfile.close ();
}
}
And here is an example of da file it saved
2
TITLE:
Bad Day
Date & Time:
06/19/2005 04:19:27 PM
MEMO:
Today is da worst day in my life..
.....................................
TITLE:
Good Day
Date & Time:
06/20/2005 04:19:27 PM
MEMO:
Today is a Good day.
.....................................
Now this (2) is the number of memos in my file
but now i got a problem which is...as soon as close my programe and run it again , and ask da program to display da memos , it cant display it well , cause it cant read it from da file...
da other problem is , if i added a new entry before i load da file , all da old enteries will be deleted... it will over write on it...
So... i need to know what shall i do , and what is da prober load function i can use , where i have 3 string , in dat node i load....
My regards ,
Bahy
|
|
|
|
|
ana_bahy wrote:
and ask da program to display da memos , it cant display it well , cause it cant read it from da file...
That's normal because when you open the file, its contents are destroyed. Try to use that instead:
ofstream outfile("c:\\queue.txt",ios::out | ios::app);<br />
ana_bahy wrote:
da other problem is , if i added a new entry before i load da file , all da old enteries will be deleted... it will over write on it...
We cannot guess what's happening during the load if you don't post the code.
And please, use the formating tags to make your code look better (it is just above the emoticons, use the 'code' or 'pre' tag).
|
|
|
|
|
Thank you soo much for ur fast reply , i really appriciate that
Here is my load code
//////////////////////////////////////////////////////////
char cqueuetype::infile()<br />
{<br />
char Title[30];<br />
char Content[100];<br />
char Date_Time[36];<br />
<br />
ifstream infile("c:\\queue.txt",ios::in);<br />
cout<<"\n\n\n\t Data are be saved now\n\n\n"<<endl;<br />
infile >> counter;<br />
for (int b=0;b<counter;b++) <br />
{ <br />
<br />
infile.ignore(7);<br />
infile.get(Title,30,'#');<br />
infile.ignore(13);<br />
infile.get(Date_Time,36,'#');<br />
infile.ignore(6);<br />
infile.get(Content,100,'#');<br />
node* temp;<br />
temp=new node;<br />
<br />
temp->Title=Title;<br />
temp->Date_Time=Date_Time;<br />
temp->Content=Content;<br />
temp->next= NULL; <br />
if (front==NULL)<br />
{<br />
rear=temp;<br />
front=temp;<br />
temp->next=NULL;<br />
}<br />
else<br />
{<br />
temp->next=front;<br />
front->next=temp;<br />
front=temp; <br />
}<br />
} <br />
infile.close();<br />
return 0;<br />
<br />
}
/////////////////////////////////////////////////////////////
My regards,
Bahy
|
|
|
|
|
Remarks:
for (int b=0;b<counter;b++)
|
|
|
|
|
for (int b=0;b<counter;b++)
|
|
|
|
|
Ok ok ok !! Stop it Don't overflow the forum by trying to format it
for (int b=0;b<counter;b++)
|
|
|
|
|
The only way to print a < symbol is to use the tag next to the 'code' tag. But ok, I understood what it was... And when you say that it cannot load the data, what is exactly the problem ? (Try to be as much precise as possible).
|
|
|
|
|
Do u have A personal email , to send u da file?
|
|
|
|
|
Other peope here are also able to help you. I don't know if I can solve your problem so it is better to post everything on the forum. And I don't need your source files because I don't have the time to run a project for that.
Better try to understand your problem and then give here a good description of what is happening. Also, a tool that could help you a lot is the debugger (press F9 to set a breakpoint somewhere in your code and press F5 to start the debugger). You will be able to watch the different variables and see what's happening.
|
|
|
|
|
Its ok... Thanks anywayz for your help... :->
My regards,
Bahy
|
|
|
|
|
Hello,
ana_bahy wrote:
but now i got a problem which is...as soon as close my programe and run it again , and ask da program to display da memos , it cant display it well , cause it cant read it from da file...
does <a href="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vcstdlib/html/vclrf_istream_basicistreamgetline.asp" rel="nofollow">ifstream</a>[<a href="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vcstdlib/html/vclrf_istream_basicistreamgetline.asp" target="_blank" rel="nofollow" title="New Window">^</a>] help?
Example:
std::ifstream infile("c:\\queue.txt",ios::in);
char Buf[256];
::SecureZeroMemory(&Buf[0], 256);
infile.getline(&Buf[0], 255, '\n');
Behind every great black man...
... is the police. - Conspiracy brother
Blog[^]
|
|
|
|
|
I'm currently using SetDlgItemText to change the text in the edit boxes, and each of the edit boxes has OnChangeEdit function that runs as soon as its contents are changed. Now in a few rare cases, I need to change the contents of the edit box without starting the OnChangeEdit function. Is there a way to temporarily disable that function or modify the contents of the box without OnChangeEdit noticing? I just wanted to know if there is an easy way to deal with this before I start writing code that complicates my program.
|
|
|
|
|
I think the easiest way for doing that is use a member variable of the class. Use a boolean for example. And, at the begining of your OnChangeEdit function, check if this boolean is true or false. If it is false, return, otherwise continue.
I don't think this will complicate your program a lot
|
|
|
|
|
You obviously type faster than I do... (See my post below...)
|
|
|
|
|
Yes, it seems ... But I think it is a rather common solution also
|
|
|
|
|
I have not ever been aware of such a command, not since Windows 3.1 anyways.
I usually set a boolean that I test in the OnChangeEdit. If the boolean is true, then just return from the OnChangeEdit. Set it before changing your text, clear it after done changing the text.
|
|
|
|
|
I want to translate ,scale and rotate a polygon
using win32 GDI or API's
you can also use the XForm matix to achive this
i'am unable to do it properly ,could some one help on this
thanks in advance
pradish
thanks in advance
pradish
|
|
|
|