|
Only keenness keeps people focused and on task. Your Super-Cop application is going to fail.
(bit philosophical, this time)
Veni, vidi, vici.
|
|
|
|
|
CPallini wrote: Only keenness keeps people focused and on task
At one place that I worked at, there was this giant ogre about 8 feet tall that would walk around the office with a whip in his hand. He kept everyone very keen and focused upon work.
Chris Meech
I am Canadian. [heard in a local bar]
In theory there is no difference between theory and practice. In practice there is. [Yogi Berra]
posting about Crystal Reports here is like discussing gay marriage on a catholic church’s website.[Nishant Sivakumar]
|
|
|
|
|
So Rajesh was your workmate!
Veni, vidi, vici.
|
|
|
|
|
CPallini wrote: Only keenness kneenness keeps people focused
You know with a whip, a hot iron to leave marks and impossible deadlines...
Eveyone on their knees! MUWHAHAHAHAHA!
PS: this also works, the only drawback is that it is difficult to maintain people alive without eating and so... and it happens that you spend a lot of whips on formation...
|
|
|
|
|
Veni, vidi, vici.
|
|
|
|
|
The title says it all. I am a noob at c++/c programming and I want to get a console application run in a powershell/terminal kind of environment. Please help!
|
|
|
|
|
|
infectedprof wrote: run in a powershell/terminal kind of environment.
Where "kind of" means exactly those?
Or you want to write your own environment?
|
|
|
|
|
Yeah its own environment.
|
|
|
|
|
Then investigate the system/process command.
Then learn how stdio/stderr/stdin work.
Then write a app that does the following
- Takes user input for "dir"
- Execute the OS dir (shell command)
- Return the output to the user.
- Do the input and output in a gui display box.
Once you do that successfully then you will have a better basis for doing something else.
|
|
|
|
|
Just open a powershell or terminal window, and type the program name at the command prompt. If you have not worked with commands before then type 'help' at the prompt and it will list the available commands.
One of these days I'm going to think of a really clever signature.
|
|
|
|
|
I have worked on Powershell,command prompt and the Linux terminal before. I am just wondering how people make environments like mintty. Is there a way I can make my own or call another one that's already pre-written?
|
|
|
|
|
I'm not familiar with mintty, although I have worked on Linux and used cygwin. Maybe if you gave some more details of exactly what problem you are trying to solve we could make some better suggestions.
One of these days I'm going to think of a really clever signature.
|
|
|
|
|
how i can use any project to work at it
and i entered my email
eman
|
|
|
|
|
Your question isn't very clear. Try rephrasing...
|
|
|
|
|
Hi all,
I want to have an interface for setting and getting the different value from/to com dll.
The value can be of any datatype, i,e it support int, char, long, short, string.
Can any one suggest how to handle this.
I know we cant have virtual template function or interface as a template.
Any idea is highly appreciated.
Thanks in advance.
regards,
Durga
|
|
|
|
|
You may use a VARIANT[^] data type or a similar mechanism.
Veni, vidi, vici.
|
|
|
|
|
One generic solution that might be suitable has already been posted by CPallini. Another one more C++ish solution could be something like this:
Define a base class for your different types:
class CValue
{
};
Derive a class for all types you support:
class CStringValue : public CValue
{
public:
private:
std::string m_Value;
};
class CIntValue : public CValue
{
public:
private:
int m_Value;
};
The advantage of this solution that your data type can be anything, it can contain an int array, or one of your own classes if you want and not just 'primitives'. The derived class itself can be a type put together by compositing other types... Your interface methods should look like the following:
void SetValue(CValue* val);
CValue* GetValue();
We reached the point where we want to use the actual value but inside SetValue() all we have is a CValue* that is useless in its current form so we put in some useful virtual methods in this base class. First I want to be able to decide the exact type of the value. For this reason I usually use one or both of the following methods:
1. introducing an enum that contains a member for each supported possible datatype and you can query it from the base class.
2. virtual downcast methods in the base class.
class CStringValue;
class CIntValue;
class CValue
{
public:
enum EType
{
EType_String,
EType_Int,
};
virtual Etype GetType() = 0;
virtual CStringValue* AsStringValue() { return NULL; }
virtual CIntValue* AsIntValue() { return NULL; }
};
Note that both the type enum and downcast methods are against the dynamic extensibility of the class hierarchy from outside world, other libraries. In some cases this isn't a problem at all, it depends on the actual problem. You might omit this whole enum + downcast method thingy as it is. You might be OK with a few other kind of virtual methods that follow:
You can put in for example some kind of serialization/deserialization methods. One often used handy serialization format is the string!
class CValue
{
public:
virtual std::string ToString() const = 0;
virtual bool SetFromString(const std::string& s) = 0;
virtual void SaveToXml(XmlElement* node) = 0;
virtual bool LoadFromXml(XmlElement* node) = 0;
};
EDIT: In case of fixed type hierarchy the visitor pattern might come handly depending on the kind of the problem.
class CValueVisitor;
class CValue
{
public:
virtual void accept(CValueVisitor* visitor);
};
class CValueVisitor
{
public:
virtual void visit(CStringValue* v) = 0;
virtual void visit(CIntValue* v) = 0;
};
If you use visitor then you can implement even the aformentioned serialization methods as visitors. Whether to use virtual methods in your base class, or to use visitor instances depends on your actual problem.
modified 30-Sep-12 11:39am.
|
|
|
|
|
Thanks pal.
Thanks for ur input. I will try using the first method.
|
|
|
|
|
You are welcome! Depending on the complexity and the requirements of your project my solution can be a heavy over-engineering to solve a very small problem. You have to draw the line yourself! Good luck!
|
|
|
|
|
Hi pasztorpisti,
I have one doubt. I can go with the enumerator alone , instead of having the downcast method?
Can you please explain me how it has to be in implementation class.
Thanks in advance.
|
|
|
|
|
I don't exactly know the problem you wanna solve and don't know what part is unclear for you. If an enum + GetType() is enough for you then you can omit the downcast methods but either way you choose you will have to downcast the object somehow so without downcast methods you will have to use C++ static cast. As I described in some situations you might need neither the enum nor the downcast, for example if a virtual method like ToString() can do the job.
|
|
|
|
|
HI pasztporpist
As per your input i have done the code
#include <iostream>
#include <tchar.h>
#include <stdio.h>
class CStringValue;
class CValue
{
public:
enum EType
{
EType_String,
EType_Int,
};
virtual EType getDataType() = 0;
virtual CStringValue* AsStringValue() { return NULL; }
};
class CStringValue : public CValue
{
private:
std::string m_strValue;
public:
void set(const std::string &strVal)
{
m_strValue = strVal;
}
std::string get()
{
return m_strValue;
}
CStringValue* AsStringValue()
{
return this;
}
EType getDataType()
{
return CValue::EType_String;
}
};
void print(CValue *pVal)
{
if(pVal->getDataType() == CValue::EType_String)
{
CStringValue *val = pVal->AsStringValue();
std::cout<<val->get().c_str();
}
}
int _tmain(int argc, _TCHAR* argv[])
{
CStringValue *val = new CStringValue();
val->set("Hai");
print(val);
return 0;
}
Is it correct? If not tell me where i did a mistake
|
|
|
|
|
Instead of
std::string get()
{
return m_strValue;
}
I would write this:
<pre lang="c++">
const std::string& get() const
{
return m_strValue;
}
</pre>
getDataType() can also be a const method.
In you example (with the print function) I would rather use the virtual ToString() method instead of a type enum or casting.
|
|
|
|
|
Hi coders! I'm new here and I would like to ask if someone knows how to use CR in win32 application in VS2010.
I've tried looking it up in the web but all i can see are CR in MFC something like that.
I have no experience in using CR. I'm trying to learn it.
Hoping for a quick response.
|
|
|
|