Himanshu
// circtor.cpp
// circles use constructor for initialization
#include <iostream>
//#include "msoftcon.h" // for graphics functions
#include <graphics>
Himanshu
using namespace std;
////////////////////////////////////////////////////////////////
class circle //graphics circle
{
protected:
int xCo, yCo; //coordinates of center
int radius;
color fillcolor; //color
fstyle fillstyle; //fill pattern
public:
//constructor
circle(int x, int y, int r, color fc, fstyle fs) :
xCo(x), yCo(y), radius(r), fillcolor(fc), fillstyle(fs)
{ }
void draw() //draws the circle
{
set_color(fillcolor); //set color
set_fill_style(fillstyle); //set fill
draw_circle(xCo, yCo, radius); //draw solid circle
}
};
Himanshu
////////////////////////////////////////////////////////////////
int main()
{
init_graphics(); //initialize graphics system
//create circles
circle c1(15, 7, 5, cBLUE, X_FILL);
circle c2(41, 12, 7, cRED, O_FILL);
circle c3(65, 18, 4, cGREEN, MEDIUM_FILL);
c1.draw(); //draw circles
c2.draw();
c3.draw();
set_cursor_pos(1, 25); //lower left corner
return 0;
}
Himanshu
this is my source code
Stanislav
Himanshu
okk
Sujeet
Anyone has book for competitive programming in c++
Sujeet
Any good sites for that
Anonymous
Sujeet
Yaa for placement point of view
Anonymous
Hacker rank or some similar website might do the job
Alignant
geeksforgeeks.org, for instance :D
Alignant
codewars is very popular
Anonymous
I don't understand competitive programming. I get obfuscated programming but speed programming just leads to mistakes
R.
what about codeforces
Anonymous
Explain different functions in C to handle . Error during I/O operations
Alignant
What do you mean by that? In C most of error handling is based on if statements.
fopen returns null if the file wasn't open. fprintf returns a negative if data wasn't printed... etc.
There are also posix/windows tools to handle errors, but they are not exactly a part of language. Do you mean this kind of error handling?
Dima
> codes own exception system in C with gotos
Gushmazuko
Gushmazuko
Hello. How i can define this functon? line 50
Gushmazuko
i got un error
Dima
why would you redefine main
Dima
you cant redefine main that way
just call it inside
Gushmazuko
like this
void main()
{
printf("In 1st main\n");
func1();
}
#define main func1
void main()
{
printf("In 2nd main\n");
}
Gushmazuko
Igor🇺🇦
How can you have several mains? Main is an entry point and loader calls it first
Dima
you cant have two mains
Dima
or you want to chose which one?
Gushmazuko
just with
main()
it's work, but i can't do the same with
WINAPI WinMain
Dima
I don't get what you want, but maybe this?
#ifdef MAIN1
void main()
{
func1();
}
#else
void main()
{
func2();
}
#endif
Gushmazuko
Gushmazuko
no
Gushmazuko
like this
void main()
{
printf("In 1st main\n");
func1();
}
#define main func1
void main()
{
printf("In 2nd main\n");
}
Gushmazuko
👆🏻
Dima
Igor🇺🇦
Why can't you give proper name to your functions?
Gushmazuko
Gushmazuko
Igor🇺🇦
You have only one main
ruki
Roxifλsz 🇱🇹
/warn advertising
Anonymous
Hey guys how can i use button and link with my header files in c++ please help me
Anonymous
no
Can still promote them then finally add
Anonymous
Hey guys!
Anonymous
I am studying classes and objects with an app but i don't understand
Anonymous
What's classes and objects?
Anonymous
Can I make an assumption? Is C++ more popular in here than C?
Anonymous
If I needed objects or classes, I generally just make structs as I don't believe OOP is a useful paradigm
Anonymous
fajar
Anonymous
Anonymous
Yes, I try to keep to C where possible
Dima
I remember there is unofficial thing called C+ (I forgot the real name), like you can use basic c++ stuff (classes, oop) but don't use std, minimize template usage, don't use all modern features (> C++11), it's great concept
Dima
thats what I use
Anonymous
For example, the IP structs in C could well have been classes in C++, but a struct works perfectly well without classes or anything that comes with it
Dima
did you write really large projects in C?
Anonymous
Yes, I wrote a minimal browser entirely in C
Dima
Anonymous
Dima
loool
Anonymous
Anonymous
I've written a text editor with GTK in C
Anonymous
Didn't. The browser was a text based browser (links style)
Dima
I remember doing one large thing in C but later moved to C++ because I got exhausted of naming all methods with prefixes and so lol
Anonymous
Manuele
another problem is that, even if C is the fastest language, it's not automatic that you get the best result. for example, graphical libs with C bindings aren't very good
Anonymous
Personally, I prefer the standard X11 libs but I'm a very minimal developer
Igor🇺🇦
Dima
not just that but you also set custom bit sizes for each property loool
Anonymous
I try and avoid a case which would require classes wherever possible
Anonymous
There is always a way to write things without classes, which it the way I tend to try and use
Anonymous
Anonymous