|
Basically, it doesn't matter what you code, you can always choose to approach it from an OOP perspective. So, then it's just the question of what you want to create.
I often create (small) tools, math-gimmicks like prime-number searches, and 'technical test projects' (to test out a specific API/environment/library for the purpose of learning).
Others are more inclined to program games, or simulations, for instance.
I think a pitfall in this case with creating a program in C++ is that it's all too tempting to use what you know in C and do it like that (though you'll have to consider for yourself if that applies).
As soon as you have something you want to create, start thinking about the involved objects and their lifetime. Start simple, for your first project, and limit the complexity and amount of classes. Most of OOP is about dividing functionality and responsibility among classes and determining their lifetime, and modelling the interactions between them. A good strategy is to make each class responsible for exactly one thing and to use a 'black box' principle: other code/classes should only concern themselves with what the class does for them, and not 'how' it does it. A rule of the thumb related to this is that if you start writing code in class1 like class2->memberClass->someMethod() that something is wrong, because now class1 needs to know the rules of class2::memberClass, which violates that black box principle. Of course, this is only a guideline and not necessarily is wrong.
Good luck
|
|
|
|
|
|
Pick up Visual Studio and play around writing MFC apps. It will give you a nice into to classes, OO, UI design, and you can knock up some interesting apps.
I use MFC a lot writing test programs for my Windows drivers and is an excellent technology.
==============================
Nothing to say.
|
|
|
|
|
static int pstate_param_set(char *val, int kp)
{
return 0;
}
static int pstate_param_get(char *buffer, int kp)
{
return 0;
}
struct mystruct
{
int (*set)(char *val, int kp);
int (*get)(char *buffer, int kp);
};
static struct mystruct jober = {
.set = pstate_param_set,
.get = pstate_param_get
};
==============================
Nothing to say.
|
|
|
|
|
|
Error . then two missing ; errors
==============================
Nothing to say.
|
|
|
|
|
Good link!
I have been wandering around the net trying to find the answer. SO it seems it is a C only method of struct func pointer initialisation. Interesting.
==============================
Nothing to say.
|
|
|
|
|
Nah, doesnt work as C code with VS either.
error C2059: syntax error : '.'
And it is C code, I checked by declaring a variable after a func, it gulched at that, so it is deffinitely seeing it as C code.
==============================
Nothing to say.
|
|
|
|
|
|
Exactly: it still does not.
Veni, vidi, vici.
|
|
|
|
|
Cheers Chris, I thought that was the case.
==============================
Nothing to say.
|
|
|
|
|
So what is the specific VC compiler output?
|
|
|
|
|
error C2059: syntax error : '.'
==============================
Nothing to say.
|
|
|
|
|
ok i have a problem with MFC, i have two dialogs and an additional class, in first dialog i create an object of my custom class and set its values, now i want to pass my object to an other dialog to manipulate it, how can i do that?
|
|
|
|
|
Just rewrite the dialog contructor passing it a handle or pointer to your object.
==============================
Nothing to say.
|
|
|
|
|
im noob in this topic could you show me an example?
|
|
|
|
|
You can also chenge the information between your main application and a dialog modal in few ways, which you can see here[^], there you have some exmaples ...
|
|
|
|
|
Yesh, override the dialogs DoModal() func (ie just add a new constructor that takes the params you want.)
In your implementation of DoModal() you copy the params locally, and then call the base class DoModal().
When your other dialog or whatever creates your new dialog, it passes the required params to the DoModal() func.
MyNewDiaolog * dialog = new MyNewDialog;
dialog->DoModal(<add your="" params="" here="">);
==============================
Nothing to say.
|
|
|
|
|
It's usually not a good idea to tie the dialogs together like that. It makes them too interdependent. Consider keeping the data in the custom class (complete with getters and setters) and creating an instance of that class in the CWinApp -derived class. Each dialog can then get access to that single instance using AfxGetApp() . This is similar to what is happening when have a document (and a view). The data, shared by the entire app, is stored in the document. When you want to access that data, you ask the document for it.
"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
"Show me a community that obeys the Ten Commandments and I'll show you a less crowded prison system." - Anonymous
|
|
|
|
|
Returning a pointer to the app class, allowing a dialog class to access data internal to the app class does what exactly in terms of following the Object Oriented methodology?
A typical hack. That is why OO design allows for polymorphism, so that data can be passed around as required. Overriding the dialog constructor then is actually a purer OO way of acchieving what he wants.
==============================
Nothing to say.
|
|
|
|
|
I need to integrate a facebook login in my application so I want to know if there are library to add!!!!! Thanks in advance.
|
|
|
|
|
Member 10005632 wrote: need to integrate a facebook login in my application so I want to know if there are library to add!!!!! Thanks in advance.
could you please provide more information regarding your project... for what you want to use FaceBook information? for Authentication purpose or you want to use some other information in your project.
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow Never mind - my own stupidity is the source of every "problem" - Mixture
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
Support CRY- Child Relief and You
|
|
|
|
|
I want to use this for authentication purpose and later I want to add some friends into the community. My project is an application like skype.
Thanks!!
|
|
|
|
|
I just read an article which augues that coding with only one programming language would limit one's capability to code.
I'm a little confused about this argument, because I've always thought that, one developer proficiently mastering one language outperforms one using many language but he actually knows relatively little about each one.
So, I'm not sure whether the idea of the passage I read is very correct.
I just want to hear more opinions about this issue, so, please feel free to show your thoughts about it.
|
|
|
|
|
I suspect they're concerned about paradigms more than actual languages. If you know only imperative languages or only functional languages for instance you may have trouble solving problems that are better suited to the other paradigm. You may know several imperative languages, but you still may not easily solve problems suited to functional languages.
|
|
|
|