Anonymous
Thats why i asked
Anonymous
redfox
How can i access a class instance in a function
redfox
Let's say that i have made a class instance in the int main and i wast to be able to access the same instance in a function
redfox
How can i do it
Marcio
The function must be a friend function of the class. Read about.
klimi
Thats why i asked
Then you should have said so in the first place
klimi
Along with description what you expect to see and what in reality you see, and probably add your code too
Anonymous
klimi
I am sorry, i am new here
These are general ideas that apply globally
redfox
class Point { public: double x, y; }; class Vector { public: Point start, end; }; int main() { Vector vec1;// define vec1 of Vector class vec1.start.x = 3.0; vec1.start.y = 4.0; vec1.end.x = 5.0; vec1.end.y = 6.0; }
redfox
this is the code i want to write
redfox
but i want the vec1.start.x = 3.0; vec1.start.y = 4.0; vec1.end.x = 5.0; vec1.end.y = 6.0; part to be defined in a function
Anonymous
#include <stdio.h> #include <stdlib.h> int main(void) { int size,i,j; printf("enter the array size"); scanf("%d",&size); int a[size]; printf("enter the array elements"); for(i=0;i<size;i++){ scanf("%d",&a[i]); } for(i=0;i<size;i++){ if(a[i]%2==0) { for(j=i;j<size;j++){ a[j]=a[j+1]; } size--; } } printf("the values are\n"); for(i=0;i<size;i++){ printf("%d ",a[i]); } return EXIT_SUCCESS; }
Anonymous
This is my code, but i am not getting proper output
redfox
what typename should i use
redfox
this is the code:
Marcio
This is my code, but i am not getting proper output
Check your braces… the printf seems to be “flying”…
redfox
class Point { public: double x, y; }; class Vector { public: Point start, end; }; int main() { Vector vec1;// define vec1 of Vector class vec1.start.x = 3.0; vec1.start.y = 4.0; vec1.end.x = 5.0; vec1.end.y = 6.0; }
klimi
Means?
Explain, what do you mean by that code.
Anonymous
a[i] is a array with integers contains even and odd numbers, i am trying to delete even number from that array
klimi
a is a pointer
Anonymous
Actually i am in learning stage, i am not a pro
klimi
And you with & you are taking the address of a pointer of int
klimi
Actually i am in learning stage, i am not a pro
Have I said such somewhere? Or what is this comment purpose?
Anonymous
I am explaining my situation
redfox
There is no problem
redfox
i have made a class instance in the int main and i wast to be able to access the same instance in a function
Anonymous
Oh, okay
Can you help me with that program? I am not getting output
redfox
Oh okay :D
There is a problem but not that type of problem I just want to make the value assignment in another function then main
klimi
Can you help me with that program? I am not getting output
Well I am trying to help but you seem to be ignoring my comment
redfox
How tho
klimi
I didn't get this
You need to provide an address where to store the int, but you are not doing that
Михаило
I need help😣 What different is between printf("___"); and cout<<"____";
Михаило
Because in school we learn with printf... but when i search tutorials i find with cout...
Михаило
I hope you understand me bc my English is terrible
Михаило
Dev C++
Михаило
And when I search Dev C++ i get with cout
Danya🔥
Do not search Dev C++
Danya🔥
It is terrible
Михаило
Then what to search
Anonymous
I need help😣 What different is between printf("___"); and cout<<"____";
printf("___") it's from C std::cout « "___" it's from C++ That's the difference
Михаило
Thank you bro
Anonymous
no problem bro😉
Artur
Anyone can suggest a good book about architecture and design for software ? Something to read and improve for work ...
Anonymous
Hi
Anonymous
Anyone can suggest a good book about architecture and design for software ? Something to read and improve for work ...
This is a vast field and there is no one book that does it all. There are different books for service oriented architecture, microservices design, cloud architecting, risk aware architecting and so on. And now the line between development/testing and devops has blurred so much that developers are required to be atleast familiar with Devops tools. More so for architects where they should know CI/CD, Ansible, Puppet or Chef like the back of their hands. Even if it is just pure software design that you are interested in, the landscape is changing. People are moving away from Object Oriented Analysis and Design which was the best thing in software world over the last decade. This is primarily because objects encapsulate mutable state and also share state both of which lead to data races in mukticore programming and hence OOAD is not conducive for concurrent programming. Locks don't help either because they are not composable. So functional programming is back in fashion now and there are so many books on this topic. So look at what you want to learn first
Shourya
Sorry I cudnt resist my self from sharing my experience of taking interviews of about 20 guys..10+ years exp guys!Out of 20 candidates 19 just explained me OOP as 3 pillars ..Real word realisation etc n blah blah..! One guy was close to explain that ...! What is up to the people?Wrong books wrong notes ?This is 16k+ group how many of you know OOP in real ?N how many of u ever read a good book or tutorial!N how many of u know uncle Bob😂
Shourya
Read my post above yours
What a timing ! I too switched to functional paradigm..But still in interviews people ask OOP and me too...And job major openings are for OOP..And specially for fresher OOP is required...But looking at their answers ..Uncle Bob will be angry😂
Fetheddine
Hey guys i have a question what kind of project i can do with c language
Fetheddine
Iheard about sdl but now its sdl 2 and we code in c++ and not in c
Fetheddine
Any sugestions please!
Anonymous
c++ also can use it
Anonymous
just import the header?
Swathi
Can i get the programming answers
Swathi
For c language
klimi
Can i get the programming answers
What do you mean by that?
J
Iheard about sdl but now its sdl 2 and we code in c++ and not in c
You can use sdl2 with your C++ program. Just don't forget to include SDL2 headers.