The plan is to add a new method 'resize' where a new array will copy the contents of the first original array and modify the already existing 'add' method to call 'resize' when necessary.
Up till now, in the constructor I created the new array, should I give the array a default value?
void resize() { int* resize_arr = new int[size + 1];
[Code] ....
i came across this code to dynamically resize an array...and here in the last statement they have deleted resize_arr.As resize_arr and arr points to samething...i think that memory that arr pointing to is also deleted...i guess correct thing would be delete [] arr....before we assign resize_arr pointer to arr...!! i am new to c++...
I'm working the 4th problem in chapter 14 of the Jumping into C++ book. In the book, he gives an example program for dynamically resizing an array while the program is running. It works fine for integer types but i need to do the same with a string type array. Right now my program is crashing because the string array is not resizing itself. Here's the part of the code im trying to figure out. The part for the int array has been ignored using // since it works fine and I'm trying to figure out whats wrong with the string array.
Code: #include <iostream> #include <string> //Write a program that lets users keep track of the last time they talked to each of their friends. //Users should be able to add new friends (as many as they want!) and store the number of days ago
I wanted to make the terminal screen bigger in my NCurses program. Let's say if the defaults are 25 LINES and 80 COLS, I want to set them to 40 LINES and 120 COLS.
I've tried resizing all windows, but that did not work, because the actual terminal (console) was not resized. Then I found functions resizeterm and newterm, but they did not work. As far as my understanding goes resizeterm only updates NCurses information with the current configuration, while the window itself is not actually modified.
NCurses man page wrote:The function resizeterm resizes the standard and current windows to the specified dimensions
If I haven't made myself clear ( I sometimes make a mess of things... ), another example would be that I want my program to be fullscreen when I start it. Is this possible? It should be, I found a fullscreen NCurses program once, but the code was too confusing for me to understand.
Having read about things like SIGWINCH, I assume you must define a method for resizing the terminal screen yourself, I don't know where to start?
I have a 2D array, array[20][3]. Each row represents a storm and each column represents month #, wind speed, and pressure in that order. This data is read from a file and auto-fills the array. I need to be able to give users the ability to add an additional storm or delete a storm. I know that a linked list would be the best approach but I'm not very familiar with linked lists.
i was trying to make a program that will asks the user for 10 numbers.then asks the user to enter integer search key.next,the program should find the value in element.i used linear search.my code is like this:
#include <iostream.h> #include <conio.h> int linearsearch(const int [], int, int);
[Code]...
how should i make a program that will uses binary search instead of linear search?
So I have linked list and function which deletes element if next element is bigger, so my code is working but its not working with first element, in the comment I have wrote code which I would code for checking that first element, but when ever I check it is blowing up all program.
#include <iostream> using namespace std; struct llist { int x; llist *next;
I have a tabbed CDockablePane with 3 Panes in total lets say Pane1 is main pain and Pane2 and Pane3 are added to the Main pain with AttachToTabWnd. In each pain I have 1 control but I will also eventually add a toolbar as well. I have created a CListCtrl with each pane. I call Override OnSize to resize the ListCtrl when the pane resizes. Problem is when I resize the width (enlarge) it does not update. If I drag the right border 1 pixel to the left it does update correctly. I have tried invalidating the pane after resize but still does not update as it should. What can I do to remedy this?
I'm having some issues understanding why the "rectangle" in the following code isn't resizing properly. Here's the code:
#include <iostream> using namespace std; class Rectangle { public: Rectangle(double w, double h, double f) : width(w), height(h), factor(f)
[Code] .....
I tested the code with a simple multiplication factor of "2", which should result in a new width and height of 4, but instead I get an odd value that seems be close to 4.
Output:
Numerically enter the width of the rectangle: 1 Numerically enter the height of the rectangle: 1
The width of the rectangle is: 1 The height of the rectangle is: 1 The area of the rectangle is: 1 The perimeter of the rectangle is: 4
Numerically enter a number to resize the rectangle: 2
The width of the rectangle after resizing is: 2.07408e-317 The height of the rectangle after resizing is: 2.07408e-317
I'm attempting to make a matrix class, and so far I've made a member that can make a vector of vectors, but I'm not sure how to go about resizing the vectors if need be.
EX: resizeArray(3,3) should return a 3x3 vector.
Also, for some reason when I call my default member, matrix(), I get an error that says.. "Request for member numrows in myMatrix, which is of type matrix<int>[][]"
#include <iostream> #include <vector> using namespace std;
I think std::copy appears to do what I'm looking for.
I'm in need of a vector member function that would allow me to "insert" a number of elements from one vector into another vector without resizing or destroying either.
An example of what I'm wanting to do is assign the contents of two[3-5][50-54] to one[7-9][2-6]. Other than looping through both vectors using .at(), is there a way to copy this?
This would be continuous within a user controlled loop with differing elements being exchanged.
Apparently the default behavior with Direct2D when rendering is to scale everything I render based on the size of the render target/window. How can I prevent this? I want to decide for myself when to scale the image, regardless of the size of the window.
I know how to make offsets/addressing formula of a straight forward N Dimensional array but how to make an offset and a storage allocation space for something tricky like:
1. A lower and upper triangular matrix? 2. A band matrix? 3. Making an offset for ragged arrays which have different row lengths? 4.A upper/lower triangular matrix using ragged arrays?
This is not for an assignment but preparation for an exam. I don't know how to go about on finding these out.
I made one application in Visual Studio 2008. The main form is maximized, and contains many panels with different controls (like buttons, listboxes, etc,). All the controls have the dock option fixed as true in panels, and the panels occupied the whole area of form.
Now, when I try to run this application in a machine, with different resolution of the screen, the form is maximized (naturally), but the panels are not resizing, so the form has many null area. How can I resize the panel so, that they fill the whole form area?
I have QTextEdit in mainWindow. I'm trying to resize QTextEdit so height = mainwindow.height and width = height/2. That should change when I change the size of mainWindow during runtime. How can I do that?
but if the matrix is compressed_matrix type, there's something with it. the error log as below:
Check failed in file boost_1_48_0/boost/numeric/ublas/detail/matrix_assign.hpp at line 1078: detail::expression_type_check (m, cm) terminate called after throwing an instance of 'boost::numeric::ublas::external_logic' what(): external logic Aborted
Very new to programming, and I know that there must be another way on inputting a string into each array cells not by just inputting it one by one, but as a whole. My code at the meantime is: [URL]
Here's my game, what do I need to learn to make a basic GUI? (Easiest way possible for now).
--NOTE, the code was a bit too long for me to post. I can add it if it is necessary. Basically all I want are 4 buttons on the main screen, one that says "Arena," "Store," "Stats," and "Exit."
There will of course be sub menus to each option, but we will get to that later.
I have project that is on c++. it runs fine. i want to use it in my C# application as a dll. i have created its dll and but firing exception of "interprocess communication".
Is this a doable task that creating dll of an exe project and using it in C# application?
I am trying to get this to work without arrays. At the moment all I am trying to do is allow it so that when the user presses 1 the board prints with 1 replaced by X, tell me where am i going wrong. I know its not finished.
#include <stdio.h> #include <stdbool.h> char a = '1'; char b = '2'; char c = '3';
So basically I have to write a C program that, when opening the html file in a browser, looks essentially like this: (Size, position, color of the shapes doesn't matter so long as I have one of each shape and the box surrounding them. Words up top dont matter either.)
This is what I have so far: Code: #include <stdio.h> #include <stdlib.h> #define FILENAME ("A4P1.html") [code]....
Anyways i can get the individual shapes, but I don't know how to get all the shapes to appear at once..
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.