C++ :: Stack Function Is Supposed To Represent Scope Of Program
Dec 5, 2014
I am trying to make an interpreter. This stack function is supposed to represent the scope of the program, meaning scope of the variables. The START represents a new scope, and FINISH represents the current scope closing. I am trying to do a recursive function in which the stack is updated with each recursive call, which represent a new scope for each call.After i enter a new scope and the scope ends, my program prematurely terminates.
void stack(ifstream& file,Hash& Table) {
string line;
getline(file,line);
int i=0;
[code].....
View 2 Replies
ADVERTISEMENT
May 1, 2013
I will make a program to read the image in C++. And later, the image will represent by array 3D, which (x,y) represent the spatial coordinate of (height*weight) image (pixel) and z represent the intesity of those image (0-255).
In matlab, the code for do that is --> imread('image.jpg')
How can I do that in C++?
View 2 Replies
View Related
Jun 17, 2014
The following code is an example of how task are created with micro cos III in c. I am trying to figure how to create similliar code in C++. My problem is how do I instantiate objects and how to use member functions to represent task. Within the create task routine the address of function is passed as argument. How do I do this in C++? Will I need more than one class? New to embedded C++.
/*!
* @brief LED Flasher Task
*/
void
led5_task (void * p_arg)
{
OS_ERR err;
(void)p_arg; // NOTE: Silence compiler warning about unused param.
[Code]...
View 2 Replies
View Related
Apr 10, 2013
I am having trouble of exactly how "class" works. I dont know what the difference between set and get is. I have this code:
#include <iostream>
#include <cmath>
using namespace std;
class Point {
private:
double px;
double py;
[Code] .....
How to get void Triangle::setBottomLeftX(const double x) to work.
Implement the get and set member functions for the class Triangle. Use the appropriate class attributes of the class Triangle.
a. The location of the bottom left vertex is stored in the member attribute blPoint.
b. The top left vertex can be computed from blPoint and the height.
c. The bottom right vertex can be computed from blPoint and the length.
View 19 Replies
View Related
Jun 14, 2013
Are there any situations to explicitly use the scope resolution operator with global scope? I can imagine a situation like:
#include <cmath>
class IntWrapper{
public:
IntWrapper& pow(char);
IntWrapper(char);
private:
int m_int;
[Code] ....
But then I would think that the writer should have used a different name, and that using the scope resolution operator in the constructor body is still pointless...
View 8 Replies
View Related
Dec 11, 2013
I have observed that inline functions can not be prototyped. example:
.cpp file:
inline void whatever() {
cout<< "this is inline"<< endl;
}
.h file, prototype
inline void whatever(); //would ask for a definition
Because of this, I have have just made functions that are used in only 1 .cpp file (ever) inlined, to make it more efficient (and it has demonstrated that it is more efficient). It's worked out fine so far, but what about the scope of the definition??
Since an inline function is like a templated function, in that it can't be prototyped, how are name conflicts resolved, and what is the best practice for writing inline functions??
Example of a conflict:
//in some arbitrary header...
void do_somthing();
//in .cpp file that inlcudes the header...
inline void do_somthing() {
cout<< "I'm doing somthing!!"<< endl;
} int main() {
do_somthing(); //which one?? it compiles fine though!!
return 0;
}
View 2 Replies
View Related
Jan 30, 2013
The compiler "forces" me to use the std::max method, I cannot override it even when writing ::max in my code.
View 4 Replies
View Related
Feb 14, 2013
So the RPG I have been making is based on this tutorial URL.....I don't entirely understand how the Item storage system is supposed to work. It looks like the array shown is for one item but, there are 3 lines of code that correlate. The author says that this is a repeatable bit of code for each item so.... i'm just completely lost. The player will have two or three to start and there are 4 battle/health items and one key ....
View 2 Replies
View Related
Oct 2, 2012
I run the following API to put Windows XP SP3 into sleep (or standby mode) from a worker thread:
Code:
BOOL bForced = TRUE;
SetSuspendState(FALSE, bForced, FALSE);
Then in the main thread, while processing window messages:
Code:
LRESULT WindowProc(UINT message, WPARAM wParam, LPARAM lParam) {
if(message == WM_POWERBROADCAST) {
if(wParam == PBT_APMSUSPEND) {
AddLogMsg(_T("SUSPEND event received"));
[Code] ....
So when SetSuspendState is called with request for a 'forced' sleep mode, the PBT_APMSUSPEND notification is never broadcast. Only if I set forced parameter to FALSE I receive it.
PBT_APMRESUMEAUTOMATIC is received in either case.
PBT_APMSUSPEND is always received when run on Windows Vista/7.
View 1 Replies
View Related
May 13, 2014
I've got this sorting program that uses variables from another class but I'm not sure why its not recognizing it. I'm getting an error length and list not declared in this scope.
#include <iostream>
#include "arrayListType.h"
using namespace std;
template<class elemType>
class orderedArrayListType: public arrayListType<elemType> {
[Code] ....
View 1 Replies
View Related
Sep 7, 2014
I am trying to use pointers in a stack program. But i am failing. my push function takes in the array,item im pushing, the reference to the top, and the size of the array.
void push(char stack[], char item, int *top, int max_size) {
if(&top==(max_size-1)) {
printf("Stack is Full");
return;
} else {
*top=+1;
stack[*top]=item;
} return;
}
And in the main function i pass a randomly pick char value, print it first , and pass it to the array using the push function
#define STACK_SIZE 10
#define STACK_EMPTY -1
int main(){
char s[STACK_SIZE];
int s_top = STACK_EMPTY; // The index of the top of the stack
int *top= s_top;
int max_size=STACK_SIZE;
[Code] .....
I know I am not referencing and dereferencing correctly and probably other stuff also. but i get these 2 errors:
stack.c: In function "push":
stack.c:23:9: warning: comparison between pointer and integer [enabled by default]
if(&top==(max_size-1))
[Code] ....
View 3 Replies
View Related
Sep 14, 2014
i wrote a program using pointers in a basic stack program below is the pop and push functions and their calls in main. basically getting random numbers and converting to char characters and inserting them into an int array.
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
[Code]....
View 9 Replies
View Related
Dec 14, 2013
i try to write a postfix calculator program using stack in C++ the in put must be the infix expression but can dont know how to write a infix expression in put.
this is my code :
#include <iostream>
#include <stdio.h>
#include <math.h>
#include <conio.h>
using namespace std;
}
[code]....
View 2 Replies
View Related
Sep 28, 2014
My errors are at the end of the program in two function calls within the definition of the InsertByValue function. g++ does not seem to recognize NumArray as a valid parameter.
#include <iostream>
#include <assert.h>
using namespace std;
const int CAPACITY = 20;
/* Displays the content of an int array, both the array and the size of array will be passed as parameters to the function
@param array: gives the array to be displayed
@param array_size: gives the number of elements in the array */
void DisplayArray (int array[], int array_size);
[Code] ....
View 1 Replies
View Related
Mar 27, 2014
I keep getting the same error messages every time on Visual Studio. I don't know where the error is originating. Basically I'm trying to convert an infix expression (A+B-C) to a postfix expression (AB+C-) using stacks.
#include <iostream>
#include <fstream>
#include <string>
#include <stack>
#include "Expression.h"
#include "stackType.h"
using namespace std;
int main() {
string fileName;
string infixExpression, postfixExpression;
[Code] .....
View 2 Replies
View Related
Sep 29, 2013
How to write a programme that take strings from file and push it into the stack with number of each sting string before it and later clean the stack?
View 6 Replies
View Related
Apr 26, 2014
Write a program that evaluates postfix expression using array implementation of stack.
The expression [the input] is evaluated from left to right using a stack. When the element read from the expression is an operand, push it into the stack.When the element read from the expression is an operator: Pop two operands from the stack.Evaluate the two operandsPush the result of the evaluation into the stack.
The final result lies on the top of the stack at the end of the calculation. Make sure to display the result before terminating the program.Write a program that evaluates postfix expression using array implementation of stack.
Code:
#include <stdio.h>
#include <string.h>
#include <stdbool.h>
#define M 20
typedef struct{
[Code] ....
View 1 Replies
View Related
Sep 24, 2014
I know that if the structure doesn't fit into the stack, it needs to be put onto the heap. But what is maximum size of a win32 stack in usual case?
View 4 Replies
View Related
Mar 26, 2013
I am trying to implement the insert function of a binary tree. Atm when I try and insert 3 nodes, the program breaks and gives me a stack overflow error. The error points to a getter function for an identifier for the data in my node class.
void LinkedList::add(Product *myProduct) {
if (_length==0) {
_head = new Node(NULL, NULL, myProduct);
_end = _head;
_length=1;
[Code] ....
Here is my insert function, the error message is
"An unhandled exception of type 'System.NullReferenceException' occurred in SDI2.exe
Additional information: Object reference not set to an instance of an object. "
In my main I have declared an instance of product, "productToAdd = new Product(id,idPrice);" so I'm a bit confused as to what I need to include..
View 3 Replies
View Related
Apr 24, 2013
The program is supposed to design a class that can be used that can represent a parabola.
Code:
#include <iostream>
#include <iomanip>
#include <cmath>
#include <fstream>
#include <cstdlib>
#include <cstring>
using namespace std;
class Parabola {
public:
Parabola( double, double, double );
[Code] .....
View 3 Replies
View Related
Sep 25, 2013
im working on Book Ordering system and i having trouble how to make the system recognize different price values when i add different books into it, also how to make the system to be able to add/remove cart?
View 12 Replies
View Related
Apr 19, 2013
Here is the code I have written so far. My problem is that when the second user enters its position the last user's position is wiped of the board. I want to know how I can hold that position and keep doing so until the game is finished. I thought that calling the previous function would do that (and you can see where I have put that into a comment) but it doesn't.
Code:
#include <iostream> //includes header file
using namespace std;
//function prototypes
void printLeftUpper(int i, int j);
void printMiddleUpper(int i, int j);
[Code] ....
View 1 Replies
View Related
Aug 24, 2014
My program has a large version of this, where every leaf class is singleton, and pointers of the base class to represent each possible path are stored in a map during compile time. I have it working as follows:
#include <iostream>
#include <string>
#include <map>
[Code].....
But System::initializePrototypes() is constructing the map manually, and I want to use recursion somehow, because my hierarchy is much bigger than this. It's also easy to miss a path doing it the above way, and when new classes are added to the hierarchy, it will be a nightmare to update the map. So the ideal solution is recursion constructing the map perfectly--and when new classes are introduced, nothing needs to be added to System::initializePrototypes().
View 7 Replies
View Related
Jun 2, 2014
I've attached an image that shows a basic table with dynamic content in the header.
Initially, I thought about using a datagrid. However, I can't use a datagrid because of the format of my data visually. The DataGrid would not allow me to have static and dynamic data inside my column headers.
You see anything I am displaying in brackets, {}, are being updated with results after I process some data in the backend. After the data analysis is done, the results are displayed based on an algorithm.
So, let's say for control1, for each family, it would indicate whether the data passed or failed. Then, in the rows themselves, it would update with choice 1 or choice 2 depending on the data generated.
So, the data that is in brackets shows properties being updated. I'm not sure what UserControl I can use to accommodate this kind of display.
View 13 Replies
View Related
Mar 15, 2013
I need to represent each inputted amount of rainfall into a graph like this.. how would I do this with loops?
View 5 Replies
View Related
Jan 15, 2015
Given a product category and subcategory representation:
a. Come up with a tree data structure to minimally (in terms of storage) represent this
b. Write a program to convert the given representation (shown in example below) to this
c. Write a function to output the tree structure in a nice human readable format
Note:
a. There can be any number of levels of depth
b. Rows may be repeated in input, but need to feature only once in the final tree.
Example category list (read this input from a file):
everything else|office supplies
electronics|video games
electronics|video games|accessories
electronics|video games|accessories|headsets
electronics|video games|accessories|flight controls
electronics|video games|accessories|joysticks
View 5 Replies
View Related