|
Right! INT 21H and such. Sounds quite distant.
I guess he is not interested in that type of things. He probably wants to mess with the Windows Console.
|
|
|
|
|
loyal ginger wrote: I guess he is not interested in that type of things. He probably wants to mess with the Windows Console.
I'd presume so as well.
It's not quite so distant for me though. I do some maintenance on an embedded system that uses a board support package that is a partial DOS work alike. I've had to reverse engineer part of its INT 21H implementation to find and patch some bugs in it.
|
|
|
|
|
Hey guys im facing a problem in declaring variables. i have a few classes like the one below...
[CODE]#ifndef _FINANCE_H
#define _FINANCE_H
#include <string>
#include <iostream>
#include <fstream>
#include <stdlib.h>
using namespace std ;
class readStraitsTimesIndex
{
public:
void StraitsTimesIndex(fstream&) ;
private:
};
class readDow
{
public:
void Dow(fstream&) ;
private:
};
[/CODE]
what i am trying to do is to use a value which is being the output of one of the class class and to be displayed into the other class. I tried using an object member like the one below ,
[CODE]class readStraitsTimesIndex
{
public:
void StraitsTimesIndex(fstream&) ;
String value ;
private:
};[/CODE]
and then assigned the output of that class to the variable(value) , but it will only work within the class. how do i go about saving a certain variable from the output of a certain class and using it for the other variables.
|
|
|
|
|
not certain I understand completely your problem, wchich sounds a lot like a very basic problem.
something like this? :
class A
{
private:
int m_a;
public:
int f(){return m_a;};
};
class B
{
private:
int m_b;
void f()
{
A a;
m_b = a.f();
};
};
or something like this?:
class A
{
private:
int m_a;
public:
int GetA(){return m_a;};
};
class B
{
private:
int m_b;
public:
void SetB( int b){ m_b = b;};
};
void main()
{
A a;
B b;
b.SetB( a.GetA() );
}
depending on the relation between A and B, this could be done in a multitude of different ways.
This signature was proudly tested on animals.
|
|
|
|
|
Sorry , let me try to make it clear.
For example, in class A, it will extract a certain value. What i want to do is to save this value in a way that it can be called out in any other classes, either for just displaying the information or to do some calculations.
|
|
|
|
|
You need to add some extra methods in your class to return the data in whatever way the caller needs. Try rereading the C++ guide(s) or books on classes and how to use them.
MVP 2010 - are they mad?
|
|
|
|
|
What should i be looking for exactly when i read the book?
|
|
|
|
|
gregarion wrote: What should i be looking for exactly when i read the book?
The fact that you need to ask this question suggests you need to look at everything. If you do not understand how classes hold their data and how they return it to other objects/callers then you are missing the fundamentals of object oriented programming; a significant hole in your knowledge.
MVP 2010 - are they mad?
|
|
|
|
|
Richard MacCutchan wrote: The fact that you need to ask this question suggests you need to look at everything. If you do not understand how classes hold their data and how they return it to other objects/callers then you are missing the fundamentals of object oriented programming; a significant hole in your knowledge.
I vote a 10 for this one! ![Smile | :)](https://www.codeproject.com/script/Forums/Images/smiley_smile.gif)
|
|
|
|
|
MVP 2010 - are they mad?
|
|
|
|
|
Well, you need something to "hold" the data that class A will retrieve.
for example If class A is simply reading data from a file, then class B could hold the data for it.
For example in MFC, you have the class CStdioFile that only reads text from a file, but in a software that use that class, I will need something to hold the text (for example a vector of text lines that are read).
Another variation, sometimes if the class is more or less specialized it could be used to read and hold data at the same time.
for example I could have a class MyStdIoFile that is derived from CStdioFile that will not only read from the file, but store the data internally.
class MyStdIoFile : public CStdioFile
{
public:
Read( CString path ){ };
protected:
vector<CString> m_Data;
}
again, there are tons of different ways of doing this, it's more a question of design than a question of code; who reads, who writes. who keep the data, who display the data, how is it read, how is it kept, how is it displayed.
Take a piece of paper and draw littles boxes representing your different objects and draw lines and arrows between them to show the relationships.
This signature was proudly tested on animals.
|
|
|
|
|
Okay , that sounds complicated. Basically why i need it to store the output given out in a certain class is because i need to use it for cppunit testing later on. Basically, each class in my project will give out a certain output based on the document it reads
For example, classA gives an output of 333.
ClassB gives an output of 434.
what i was trying to do is to try to save this values in a way that when i write my cppunit, i can use it to check if it is equal to the hardcoded input.
|
|
|
|
|
|
glitteringsound wrote: written in C#
What makes you think you can mention that abomination in this forum and live?
You measure democracy by the freedom it gives its dissidents, not the freedom it gives its assimilated conformists.
|
|
|
|
|
glitteringsound wrote: Any body can give the source of
In short, No. If you want source code then search the articles or Google. If you have a programming question then you may post it in the (correct) forums.
MVP 2010 - are they mad?
|
|
|
|
|
Hi there,
i was testing this the other day, and it compiles fine.
int Test(int a, int b, int c)<br />
{<br />
return a,b,c;<br />
}<br />
doing this;
printf("\n %d", Test(10,20,30));
will always give 30.
Can anyone explain what is actually happening in the code above, and why it is even possible to compile such a code? what does return a,b,c actually implies?
I never seen any code that does that, (all codes return 1 value), but if this code can compile, what does it mean?
(Tested using VC++2008)
|
|
|
|
|
The way the comma operator works is that it returns the last value. For instance:
int a = 1, 2, 3;
will result in a being 3. So your
return a,b,c;
is really equivalent to:
return c;
|
|
|
|
|
If so, what is the use of the comma operator? Is there real use for it?
|
|
|
|
|
for example it's used in the for statement.
for ( i = 0, j = 0;; i<100; i++, j++)
{
}
or in variable declarations:
int i, j;
and maybe many other places.
This signature was proudly tested on animals.
|
|
|
|
|
It can be overloaded. See Boost Assign[^] library for example:
vector<int> v;
v += 1,2,3,4,5,6,7,8,9;
|
|
|
|
|
Oh yes, comma is used in for loops. It's so common! I didn't realize it!
Thanks!
|
|
|
|
|
The comma operator evaluates bot operands, and evaluates to the result of the second one.
So the first operand is evaluated only for its side effects. One common use is:
<br />
while ( (c=getnextthingie(), c!=EOF) )<br />
{<br />
}<br />
here, the first operand has the side effect of calling getnextthingie and assigning the result to c. c!=EOF is evaluated as loop condition.
Personally, I love the idea that Raymond spends his nights posting bad regexs to mailing lists under the pseudonym of Jane Smith. He'd be like a super hero, only more nerdy and less useful. [Trevel] | FoldWithUs! | sighist | µLaunch - program launcher for server core and hyper-v server
|
|
|
|
|
uus831 wrote: Can anyone explain what is actually happening in the code above, and why it is even possible to compile such a code? what does return a,b,c actually implies?
See here and here.
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"Man who follows car will be exhausted." - Confucius
|
|
|
|
|
Er, yeah, if you COULD declare your function as:
int, int, int Test(int a, int b, int c);
You might get 12 bytes on the stack for your return values, but C isnt made this way!
If you realy want to wedge more values into the 32 bits you are given you could cast say a short and two chars into an int.
return (x << 16 + y << 8 + z);
for example, and then pull it apart in the calling code.
Morality is indistinguishable from social proscription
|
|
|
|
|
I am using main "standard" property sheets for tabbed application.
I would like to have another property sheet embedded in the main tab(s).
I got as far as using CStatic variable in the page, but now I am stuck.
I tried this (snippet)
position = pDoc->GetFirstViewPosition();
COpenHRView *pOpenHR = (COpenHRView*) pDoc->GetNextView(position);
if(pOpenHR->m_pPropFrame1);
{
m_sstv.Detach(); // added this when Attach asserted – no go asserts
m_sstv.Attach(pOpenHR->m_pPropFrame1->GetSafeHwnd()); // asserts– attach only once
}
return CpropertyPage::OnSetActive();
Thanks for reading. Any constructive help as always is appreciated.
|
|
|
|