C/C++ :: How To Save Triangles / Polylines Into Vector Using New Keyword
Oct 11, 2014
In C++ by FLTK, to define a circle we use some code like this:
Circle c(Point(x,y), r);
And we can using vector_ref put and save them in a vector, like:
Vector_ref<Circle> vc;
vc.push_back(new Circle(Point(x,y),r));
Ok, those were about Circle and no problem till now!
Triangle can be defined like this for using in codes:
Graph_lib::polyline poly;
poly.add(Point(x1,y1),r1);
poly.add(Point(x2,y2),r2);
poly.add(Point(x3,y3),r3);
and this is a vector to saving them:
Vector_ref<Graph_lib::Polygon> vp;
The problem is that how to save/put triangles/polylines into that vp vector using new keyword like the circle does?
My sig: Save Cobani.
View 4 Replies
ADVERTISEMENT
Jan 28, 2015
1st when i fill the things on form then saved in database after saving record when i want add another record it shows an error. after saving it saves new record refresh doesn't work
View 1 Replies
View Related
Nov 5, 2013
I am trying to develop a GUI using MFC, but I am having trouble using CFiledialog to save a file. The problem is, the file is not getting saved to the folder when I use the CFiledialog. Below is the code I am using.
Code:
CString szFilter = "XNRep Files (*.xnrep)|*.xnrep||";
CString s = "xnrep";
CString t = "";
CFileDialog fileDlg(FALSE, s, t, NULL, szFilter);
if(fileDlg.DoModal() == IDOK)
{
std::ofstream file;
[Code]....
After the file dialog opens up, I enter the name of the file and select OK button. But the file does not show up in the directory I am saving to.
View 4 Replies
View Related
Oct 15, 2013
i have an assignment where i have to draw a teapot using triangles, and are struggling with the part where i have to color it. Here is an link to the assignment URl....
I have managed to draw the teapot and translated it onto the screen. the part i need support with is making a bounding box for the triangle and coloring it.
View 5 Replies
View Related
Jun 28, 2014
One exercise says that, "Define a right triangle class. Make an octagonal shape out of eight right triangles of different colors."
Making such a class isn't difficult. I wrote it as follows:
#include "Simple_window.h"
class right_triangle : public Shape {
public:
right_triangle(Point p, int l, int sh): c(p), _long(l), _short(sh)
[Code] ....
But it sounds that making an octagon using eight right triangles isn't possible!
View 2 Replies
View Related
Sep 27, 2014
So in class our teacher assigned us a program where we have to use nested for loops to creates triangles. How does the 2nd for loop print more than 1 star? since the for loop will only run the cout 1 time until it gets to the escape sequence, how does it print more than 1 star on a line? this is what is confusing me. I feel like if i can grasp the understanding of that and what the for loops are doing i can finish the rest of this program with ease
#include<iostream>
using namespace std;
int main()
[Code].....
View 1 Replies
View Related
Mar 15, 2015
I have to Write a program to produce that makes four triangles and a pyramid. I have to ask the user they height of the triangle and prevent the user from entering a height any larger than 25. It should look like this.
Enter the height of your triangle/pyramid: 3
***
**
*
*
**
***
*
**
***
***
**
*
*
***
*****
im having tourble with 3 and 4th and also pyramid.
HERES WHAT I HAVE SO FAR.
#include <iostream>
#include <iomanip>
#include <string>
using namespace std;
int main () {
int input = 0;
cout << "Please enter the height of your triangle/pyramid: ";
[Code] .....
View 2 Replies
View Related
Jun 28, 2014
One exercise says that, "Define a right triangle class. Make an octagonal shape out of eight right triangles of different colors."
Making such a class isn't difficult. I wrote it as follows:
#include "Simple_window.h"
class right_triangle : public Shape {
public:
right_triangle(Point p, int l, int sh): c(p), _long(l), _short(sh) {
add(Point (p));}
void draw_lines () const
[code]...
But it sounds that making an octagon using eight right triangles isn't possible!
View 4 Replies
View Related
Oct 19, 2014
I have to place two asterisk triangles on top of each other BUT only using 3 for statements. I have gotten the first one:
for(int a=1;a<=10;a++) {
for(int b=1;b<=a;b++)
cout << "*";
cout << endl;
}
I need the output to look like this:
*
**
***
****
*****
******
*******
********
*********
**********
*
**
***
****
*****
******
*******
********
*********
**********
The only kicker is I can have a total of 3 nested for loop statements.
View 7 Replies
View Related
Jun 28, 2014
One exercise says that, "Define a right triangle class. Make an octagonal shape out of eight right triangles of different colors."
Making such a class isn't difficult. I wrote it as follows:
Code:
#include "Simple_window.h"
class right_triangle : public Shape {
public:
[Code]...
But it sounds that making an octagon using eight right triangles isn't possible!
View 9 Replies
View Related
Jan 26, 2014
In c# extending the class and implementing an interface is done by : symbol.. But c# has extend keyword. What is the use of extend keyword in c#?
View 8 Replies
View Related
Jun 30, 2014
for starters i hope this question wasn't posted yet.i want to write a small program that askes the user what he wants to do , and then executes the comand in system . But for some reason it doesn't quit on the key word this is the code:
Code:
#include <stdio.h>
/*a simple interaction programme that schow the system options*/
#define systemt "x1b[32m" /*changes the color to green for system output*/
#define user "x1b[0m" /*changes the color to white for user input*/
int main() {
[Code]...
Is there something wrong white the code or does the system bock me from reusing the choise string. i'll inculde the original c file as well
View 1 Replies
View Related
Jan 6, 2014
have a look at the following code :
class Base
{
public:
virtual ~Base()
{
cout << "Calling ~Base()" << endl;
[Code]...
Now this program produces the following result:
Calling ~Derived()
Calling ~Base()
i was reading online and got stuck here. i am unable to understand why 'calling ~Base()' is been printed here? when we reached delete pbase; in int main() it goes to Base class first and finds that its destructor is virtual so it goes to Derive class and finds another destructor and executes it but why does it prints ~Base() in any case?
View 4 Replies
View Related
Feb 19, 2014
How to put virtual keyword in the function of the base class. Will the function still be over-written properly? What will happen if I
(1) call function from base class pointer
(2) call function from derived class pointer
(3) call function from derived class object
If the virtual keyword is present, the over-written version will be called in all cases, am I mistaken?
View 1 Replies
View Related
Feb 14, 2014
One thing make me consider:
FistClass F1 = new FistClass ();
FistClass F2 = F1;
second line why i dont need to firstly create instance for F2 and then make reference betwwen to classes like:
FistClass F1 = new FistClass ();
FistClass F2 = new FistClass ();
F2 = F1;
View 9 Replies
View Related
Apr 6, 2015
How to find triangle in an array of n triangles which has the largest area?
#include <stdio.h>
#include <stdlib.h>
#include<math.h>
typedef struct {
double x,y;
[Code] .....
View 14 Replies
View Related
Sep 24, 2014
I'm trying to read a C code, but there are functions including CLASS word at the titles of functions. Is it a correct implementation?
For example: double CLASS getreal (int type)
What is the meaning of CLASS in titles of functions in C? I could not find such an usage in my C book?
View 6 Replies
View Related
Aug 18, 2014
I was trying to make a tic tac toe game where the user can play against the computer
It s in borland c++ and not in c++ 11 so i wanted to convert it into c++11. My program shows error since there is nothing called conio.h in c++11. Hence I want to know if there is any alternate keyword gor the function getch() so that i could ask the user to press [ENTER].
Code:
#include<process.h>
#include<stdlib.h>
#include<string.h>
#include<iostream.h>
#include<conio.h>
int usbox,i,j,nandu=0,result,cusb,cobox,r,d;
int playl=0;
char copybox[10];
[Code] ....
View 2 Replies
View Related
Sep 8, 2013
nestedTriangles.cpp description:
The program takes as input a pair of triangles, specified be giving the coordinates of each trangle's vertices. It then determines if either triangle is "nested" within the other, meaning that one triangle lies entirely within the interior of the other.
Pseudocode:
One triangle lies within another if and only if all three vertices of the first triangle lie within the interior of the second triangle.
Suppose that we have a triangle with vertices A, B, and C, described by the coordinates (xA, yA), (xB, yB), and (xC, yC), respectively. The sides of the triangle are the line segments AB, BC, and CA.
A line passing through two points (x1, y1) and (x2, y2) can be considered to be the set of points (x,y) satisfying the equation
f(x,y) = 0
where f(x,y) is given as
f(x,y) = (x - x1) (y2 - y1) - (y - y1) (x2 - x1)
One of the interesting things about that f(x,y) is that we can use it to determine which "side" of the line an abitrary point (x,y) is on:
If f(x,y) = 0, the point is exactly on the line. All points for which f(x,y) > 0 are on one side of the line, and All points for which f(x,y) < 0 are on the other side So the problem of determining whether a point (x,y) is on the inside of a trangle can be checking the sign of f(x,y) for each of the three lines making up the triangle. A complicating factor is that we don't know, for any given triangle, whether those three signs should be all positive, all negative, or some mixture of the two.
The centroid of a triangle can be computed as the "average" of the x and y coordinates of the vertices:
xcen = (xA + xB + xC)/3
ycen = (yA + yB + yC)/3
This point (xcen, ycen) is definitely inside the trangle (unless the triangle is "degenerate" and has no interior points). The problem of determining whether (x,y) is on the inside of a triangle can therefore be resolved by checking to see if it is on the same side of each of the trangle's line segments as (xcen, ycen).
What I need:
I want to fill in the missing bodies for the functions eval and areOnSameSideOf, which manipulate line segments. I think calling eval from within areOnSameSideOf will simplify the implementation of the latter.
Code:
#include <iostream>
using namespace std;
/**
* 2D Cartesian coordinates
*/
[Code]....
View 2 Replies
View Related
Sep 8, 2013
nestedTriangles.cpp description:
The program takes as input a pair of triangles, specified be giving the coordinates of each trangle's vertices. It then determines if either triangle is "nested" within the other, meaning that one triangle lies entirely within the interior of the other.
Pseudocode:
One triangle lies within another if and only if all three vertices of the first triangle lie within the interior of the second triangle.Suppose that we have a triangle with vertices A, B, and C, described by the coordinates (xA, yA), (xB, yB), and (xC, yC), respectively. The sides of the triangle are the line segments AB, BC, and CA.A line passing through two points (x1, y1) and (x2, y2) can be considered to be the set of points (x,y) satisfying the equation
f(x,y) = 0
where f(x,y) is given as
f(x,y) = (x - x1) (y2 - y1) - (y - y1) (x2 - x1)
One of the interesting things about that f(x,y) is that we can use it to determine which "side" of the line an abitrary point (x,y) is on:
If f(x,y) = 0, the point is exactly on the line.
All points for which f(x,y) > 0 are on one side of the line, and All points for which f(x,y) < 0 are on the other side So the problem of determining whether a point (x,y) is on the inside of a trangle can be checking the sign of f(x,y) for each of the three lines making up the triangle.
A complicating factor is that we don't know, for any given triangle, whether those three signs should be all positive, all negative, or some mixture of the two.
The centroid of a triangle can be computed as the "average" of the x and y coordinates of the vertices:
xcen = (xA + xB + xC)/3
ycen = (yA + yB + yC)/3
This point (xcen, ycen) is definitely inside the trangle (unless the triangle is "degenerate" and has no interior points).
The problem of determining whether (x,y) is on the inside of a triangle can therefore be resolved by checking to see if it is on the same side of each of the trangle's line segments as (xcen, ycen).
I want to fill in the missing bodies for the functions eval and areOnSameSideOf, which manipulate line segments. I think calling eval from within areOnSameSideOf will simplify the implementation of the latter.
Code:
#include <iostream>
using namespace std;
/**
* 2D Cartesian coordinates
*/
struct Point {
double x;
double y;
[code]...
View 1 Replies
View Related
Apr 13, 2013
how can I make a class non inheritable,,, without using keyword "final" ?
class A
{
//
};
A obj; // No error
class B : public A
{
//
}; // error
View 2 Replies
View Related
Jun 24, 2014
Is the bool keyword in C exactly like the boolean keyword in Java? why this code is getting an 'unknown type error' when I initiialze looping.
#include <stdio.h>
#include <stdlib.h>
int main()
[Code].....
If I am completely using the boolean concept wrong in C, should I just use break statements instead?
View 11 Replies
View Related
Jan 30, 2014
I think there is no always need of keyword extern in order to declare variables globally. Is it right?
For example I can declare a variable globally in one file and use it in some other provided that I have included the last one file ( that has the declaration of the variable of course) and compile these files together :
gcc -c f1.c f2.c for example
View 6 Replies
View Related
Nov 8, 2014
I'm working on a program that reads in a .txt file and searches through the text for a keyword. If it gets a hit on the keyword, the line number where the keyword is located and the line that contains the keyword is printed out. What I have now doesn't catch every occurance of the keyword "a".
Code:
#include <stdio.h>
#include <string.h>
int main(int argc, char **argv) {
[Code]......
View 4 Replies
View Related
Apr 25, 2014
I am reading a file whick looks like following:
Code:
10 = NAND(1, 3)
11 = NAND(3, 6, 5)
15 = NAND(9, 6, 2, 8)
Problem: I have to find the word "NAND" and then find the numbers inside the brackets because they are the inputs to that NAND gate. I have written a code below but that code can detect the fixed number of inputs. I need a code which can detect any number of inputs (whether 2 inputs or more than two). But i don't understand how do i do that?
My code:
Code:
string input_str ("INPUT"), output_str ("OUTPUT"), nand_str("NAND");
while (getline( input_file, line ))
{
std::size_t guard_found = line.find(guard_str);
[Code].....
View 8 Replies
View Related
Feb 9, 2015
How to output vector contents using the push_back function. My program reads in values just fine, but it does not output anything and I've been stuck on why.
here is my code:
#include <iostream>
#include <array>
#include <vector>
using namespace std;
int duplicate( vector < int > &vector1, const int value, const int counter)
[Code].....
View 3 Replies
View Related