C++ :: Building A Typeless Container?

Jun 14, 2013

i built a programming language called jade that right now can only print. i want to add variables to it however. I am going to use a modified bajarne stroustrop calculator to handle expressions (ie will now include string manipulations and such), but I want to build a var class into the program to make it easier for the program. i want variables to act like python variabes, and arrays to act like python associative arrays. Ive scoured different containers, but they only work if the variable isnt an array in my language, because it will only have one type. the only thing i can come up with is a union and 4 overloaded = operators (for bool, int, double, and string) is there a better way to do this?

View 2 Replies


ADVERTISEMENT

C :: Building NFA From Regular Expression

Oct 23, 2013

I am trying to create a NFA from a regular expression. I have a grasp on reading in the regular expression and being able to make a stack from it. The part I am struggling on is mapping the characters in the regular expression to an integer indicating the variables order in the expression. I am just not sure how to go about this.

My code so far...
Code:
#include<stdio.h>
#include<stdlib.h>
#include "stack.h"
int main(void)
{
char expression[80];//array to store regular expression

[Code] .....

View 6 Replies View Related

C/C++ :: Building QGIS X64 On Windows

Feb 9, 2015

Basically I want to embed the QGIS canvas widget into a custom application. In order to do that, I need to build QGIS from it's source in order to obtain the devel *.lib, *.dll, *.h, etc. files required. To that result, I am trying to build either version 2.6.* or the current nightly build ~2.7 - 2.8 64 bit version. There is very little documentation on the x64 builds. Not to mention that CMake and I are not the best of friends.

My progress so far:
- Successfully built the extremely out of date nightly build readme instructions of version 0.11 x86
- Partial success in creating CMake output to VS2010, but many required headers were not included such as gqsmapcanvas.h, (So even if I got it building I couldn't use the canvas widget in an application)
*Note I updated the external packages to x64 versions, so it is not an architecture mismatch issue.

I have also had issues with QWT looking for QWT Polar header files, but I suspect this is another issue with the missing headers as most of the errors related to files contained in the original source from GIT.

View 1 Replies View Related

C# :: Logic For Building Numbers Pyramid?

Jan 7, 2012

Code:
1
121
12321
1234321
123454321 EDIT:
the above pyramid looks like a doom.i.e 1-5 will be in center.1-4(L)1-3(L)1-2(L)1(L) similarly 1-4(R) 1-3(R) 1-2(R) 1(R)

I'm partly successful in building the requirement of the program.but cant able to think the logic for the other half. how can i proceed.below is the code written in c#.

Code:
for (int i = 1; i <= 5; i++)
{
//int l = 1;

[Code]....

View 3 Replies View Related

C++ :: Building A Matrix With Specific Dimension

Jan 23, 2015

I would like to initialize a N-dimensional matrix by specifying the dimension N.

To be clearer :

if N=2 I use to do that :
std::vector<std::vector<double>> myMatrix;
if N=3 :
std::vector<std::vector<std::vector<double>>> myMatrix;
and so on...

What I would like is to give N as an argument of a function which construct a N-dimensional empty matrix. Is that possible ?

View 2 Replies View Related

C++ :: Making / Building 3D Game Engines

Jan 23, 2013

Making/Building 3D Game Engines, Do I need to know anything related to ART or graphics in order to make them ? I mean, I do know that having a know how about vectors is VERY important, But I am no good at art, I suck. I have thought of getting a separate guy to do the art, as I'm more interested in writing code and then implementing it making use of the art that has been made, I'm just worried if I need to or not need to know anything about sketching or art in order to write a 3D Game engine ?

View 8 Replies View Related

C++ :: Building Multicast Packet - Memcpy Casting

Aug 19, 2014

I am just getting back in to C++ after 10 years not doing any, contributing to an open source project. I'm adding in some functionality and am hitting a road block.

I need to send a multicast packet out on the network that is structured in a certain way. I have the definition, and know what data is going in each byte. I can successfully send a message using multicast, I now just need to send the right message.

I have used a char array to hold the message, as each char represents 1 byte, and I can transmit the array.

I am having trouble putting all of the data in the right place though. If my source data is a string, then I seem to be able to convert it, but if it is a short or int, then I keep getting errors when compiling. Similarly, two of the lines, (version and type) i initially tried using char arrays with a length of one.

Should I be using memcpy or a different function, or even be doing this in a totally different way altogether? This is the code that I am using, along with the packet structure:

//Construct a Zone Query packet
// 4 bytes - Signature "Ohz " = 0x6f, 0x68, 0x7a, 0x20
// 1 bytes - Version = 1
// 1 bytes - Type (0 = Zone Query, 1 = Zone Uri)
// 2 bytes - Entire message length = 12 + zone length
// 4 bytes - Length in bytes of the zone ID
// n bytes - Zone ID to query

[Code] ....

The errors that I get are:

error: invalid conversion from ‘short int’ to ‘const void*’ [-fpermissive]
memcpy(buffer + 6, packetLength, sizeof(packetLength));
^
[Code] ....

View 9 Replies View Related

C++ :: Building Special Order Of Elements For Given Sequence

Jun 1, 2013

Let assume that there is an array of integer numbers in the range from 1 to N that are located in the ascending order. For example

#include <iostream>
#include <numeric>
#include <iterator>
int main() {
const size_t N = 20;

[Code] .....

How can it be converted using some one standard algorithm such a way that the resulted sequence would look like

1 3 5 7 9 11 13 15 17 19 20 18 16 14 12 10 8 6 4 2

View 19 Replies View Related

C++ :: Building Destructor That Outputs Data Before Destroying It

Mar 7, 2014

I am trying to build a destructor that takes an array pointer and outputs part of a private vector and, comparing a string within the objects, overwrites the data in the array with the data in the vector. (vector and array use same class type) It then proceeds as usual.

#include <iostream>
#include <string>
#include <iomanip>

[Code].....

View 6 Replies View Related

C++ ::  Building Database - Sort 2D Array Alphabetically

May 25, 2013

I'm using a database and im trying to sort a 2D array info[51][10] that contains 51 pieces of records and 10 different fields for each record. And, now I'm trying to sort a desired field in the 2D array alphabetically.

However, the other fields within the same record should be swapped together. (So that the information of the same records stays together).

Also, I am constantly experiencing a run-time error. Sometimes my program works sometimes the whole thing crashes... By opening the code in different folders sometimes works. But the problem is still here. Is there any way to fix this error?

bool swapped =true;
int j=0;
string tmp[10];
swapped =true;
j=0;

[Code] .....

View 1 Replies View Related

C++ :: Redirecting Network Traffic (building A Proxy)

Feb 3, 2015

I want to build a proxy, middleman between various client programs on my machine and servers outside, like this:

Client -> Proxy -> Server, Client <- Proxy <- Server.

OSes are Windows XP, 7 and 8.

Within that proxy I want to analyze data before it reaches it's destination and have full control over it to the point where I can prevent a packet from reaching it's destination if my program finds something suspisious going on. I need incoming and outgoing traffic of specific adresses and ports to be forwarded into my application on my client machine. My app then should deliver packets to their destination after they were analyzed.

The parts where data is received, analyzed, manipulated if needed, and sent is something I could code with no difficulty. But the concept of redirecting and forwarding is hard for me to grasp at the moment. I'd like to know at least what winsock functions I have to use.

If it's possible, I would like to use Windows libraries only, nothing from 3rd parties.

View 3 Replies View Related

Visual C++ :: Building A Savings Account Program?

Mar 12, 2014

#include "stdafx.h"
#include <iostream>
#include <iomanip>
#include <cmath>
using namespace std;

[Code].....

I need to modify the program to use annual interests rates of 3%, 4%, and 5%.

After that I need to modify the program to make it so the user enters the dollar amount of the deposit, the interest rate or rates, and the number of years.

I'm a design student at New England Tech but before we can go full design they want to make sure we know for sure if we want to be a designer or a programmer and so we need to take C++ classes

View 4 Replies View Related

Visual C++ :: Unresolved External Symbol When Building For X64 Platform

Jul 11, 2014

The project builds on Win32 platform, but not on x64.

Full error message: dllentry.obj : error LNK2001: unresolved external symbol "class CFactoryTemplate * g_Templates" (?g_Templates@@3PAVCFactoryTemplate@@A)

The dllentry.cpp (a DirectShow base class) compiles on both platforms. It contains the external declarations:

extern CFactoryTemplate g_Templates[];
extern int g_cTemplates;
g_Templates[] is then used in two functions:
__control_entrypoint(DllExport) STDAPI DllGetClassObject(__in REFCLSID rClsID,
__in REFIID riid, __deref_out void **pv)

[Code]...

myClass.cpp contains the definitions for the two externals in dllentry.cpp, at top level, just after the includes:

CFactoryTemplate* g_Templates=0;
int g_cTemplates=0;

myClass.cpp also compiles by itself, but the project does not build. I checked all the libraries in the project settings and all seems to be OK, the 64 bit versions are used.

What should I do to make the project build for x64 platform?

View 4 Replies View Related

C++ :: Building Binary Tree - How To Find Parent Of A Given Node

Jun 26, 2012

I'm trying this to get the hang of boost::shared_prt and weak_ptr so far I have the following

Code:
#include <iostream>
#include <string>
#include <boost/thread.hpp>
#include <boost/lambda/bind.hpp>

[Code] .....

My questions are, is the tree class defined correctly? How do I find the parent of a given node? And how does the insert part will work?

View 6 Replies View Related

C++ :: Virtual Functions - Calculate Carbon Footprint For Car / Building And Bicycle

Apr 13, 2014

I'm writing a program that calculate the carbon footprint for car, building, and bicycle. i have three classes building, car, bicycle. class called carbonfootprint have the pure virtual and should have the formula, but i didn't find it. having a little bit hard understanding some requests. like,

• Write an abstract class CarbonFootprint with only a pure virtual getCarbonFootprint method. Have each of your classes inherit from that abstract class and implement the getCarbonFootprint method to calculate an appropriate carbon footprint for that class.

• The main() function in the given program creates objects of each of the three classes, places pointers to those objects in a vector of CarbonFootprint pointers. You need to iterate through the vector, polymorphically invoking each object’s getCarbonFootprint method.

// Test program for CarbonFootprint and implementing classes.
#include <iostream>
#include <vector>
using namespace std;
int main() {
vector< CarbonFootprint* > list;
// add elements to list

[Code] ....

View 4 Replies View Related

C/C++ :: Recursively Building Cons Cell Structure Via Recursive Descent

Apr 25, 2015

I'm currently working on a Scheme Interpreter written in C. I'm trying to create a cons cell structure via recursive descent parsing, except instead of just having the car and cons, I also have a field that holds the token that I receive from the lexical analyzer (which was provided to us). The struct for what I'm describing is as such:

typdef struct node node;
typedef node* list;
struct node {
char* symbol;
list car;
list cdr;
};

Thus a cons cell would be (with a node represented as [symbol][car][cdr]), [null][car][cdr], while a symbol would be [symbol][null][null].

In the top answer for a similar question on Stack Overflow, one of the suggestions was to put the tokens into a stack as the input is recursively parsed, and then from that stack input it into the cons cell structure.

This is something that I'm working towards now, as it is easier for me to understand and I already have implemented a stack in C before, but I know that I can just build the structure recursively, I'm just not sure how. The following is code that I have:

list s_expression() {
list local;
list temp;
if (strcmp(token, "(") == 0) {
strcpy(token, getToken());

[Code] .....

s_expression is supposed to return a pointer to a recursively built cons cell structure. I'm just having issues figuring out when to call getToken(), as I either call getToken in the wrong spot and unintentionally skip over a token, or I call getToken() when I'm done getting all of the tokens, thus causing my program to continue searching for a token from user input instead of continuing on with the rest of the program.

When should I be calling getToken()?

In addition, what would be better, recursively building the cons cell structure as you go through the user's input, or putting all of the tokens into a stack and then building the cons cell structure using that stack?

If needed, I can post the lexical analyzer that's been provided to us. Also, for S_expression(); showing up as S_exp<b></b>pression();, I'm not sure what happened there. I copied this post from my question on stack overflow.

View 12 Replies View Related

C++ :: What STL Container Should Be Used For Inventory

Mar 27, 2014

So I'm writing an RPG and I'm in need of an inventory system. Of course as an relatively old member of the forum I know best than just come here and ask so I've already researched quite a bit and I've formulated this idea.

I've kind of conceptualized it like so: I'll have some sort of STL container of a unique_ptr of my base item class. There will be derived item classes. Taking advantage of polymorphism I can then call the new Derivedclass when inserting it in the STL container.

My questions are: What STL container should be used for the inventory(fixed sized)?

View 2 Replies View Related

C++ :: What Is Container Class

Sep 22, 2013

What is container class? what its advantage ?

View 2 Replies View Related

C++ :: Which Std Container To Choose

Sep 16, 2012

I have a pile of data, which i need to access frequently and fast. One entry consists of two unsigned ints, let`s call them source and destination.

One source can have several destinations, but this rarely ever happens. Several sources can have the same destination - this happens more frequently, but still scarcely.

Once the data is set up, it rarely ever changes - yet it should be possible to add or remove entries.

I now need to find all sources for a given destination, or all destinations for a given source.

The question: which stl container to choose?

I have tried a multimap, using the source as key. This works good for finding all d for a given s, but is inefficient in the other direction.

Do you think it would be more efficient to have two multimaps, sorted respectively by source and destination?

View 1 Replies View Related

C++ :: Multilevel Dynamic Container

Mar 6, 2013

I am trying to come up with a way to make use of a "multilevel dynamic" container. I am parsing a file to grab some pieces of data. Lets say the first field of data I find I push into an array. At the same time lets I wish to create 2 cascaded sublevels. So an element in Modules is a pointer to the Types vector associated with that module and each element in Types is a pointer to a vector of Data. This concept should be similar to memory paging.

/*
Modules Types Data
____ _____ ______
|____|------> |_____| ---------->|______|
|____| |_____| |______|
|____| |_____| |______|
|____|
|____|
|____| _____ ______
|____|------> |_____|----------->|______|
|____| |_____| |______|
*/

Obviously this becomes very hair quickly so it is obvious that I need to dynamically create and destroy vectors (if I do it this way). Should I just create pointers using the new operator?

Here is some of my code if it is even worthwhile to read:

class Parser {
//storage arrays
vector <string> modules;
vector <string> terminal_type;
vector <string> tag_type;
vector <string> data;

[Code] ....

parse this stuff and nicely organize it.

If you take the first one, "max_logvar" is a module so everything between < and > is associated with that module.

symb is unimportant for now.

then "proterm" is a "module type" so then module now needs a module type container but I may have more than one of those.

so then I break it down by "Input" and "Output" where each of those can have the integer values (just in an array where each position will be set) that are in the fields to the right.

View 1 Replies View Related

C++ :: Deleting Object From A Container?

Nov 21, 2013

I have a container in c++11 and i must delete first object and i don't know how...

for (const prob& p : *static_cast<vector<prob>*>(list.listData)){
// i must delete the first object
}

View 2 Replies View Related

C++ :: Container Of Hierarchy Of Objects

Apr 25, 2014

How do we design a container of objects all of which belong to some subclass which directly/indirectly inherits from a given parent class? Moreover, I would like to have functions that enable me to pick only objects of a certain class type from the container.

For example if the parent class is A and I have a hierarchy of classes that derive from it, we must have a container that can contain any class that exists in this hierarchy. Also, get_B() must be able to let me examine only those objects in this container that inherit (directly/indirectly) from class B (class B exists in the hierarchy rooted at A).

Preferably, we would like to avoid downcasting. Or even explicit typechecking of any sort.

View 8 Replies View Related

C++ :: Relation Between A Container And Allocator

Mar 30, 2014

To my understanding, a Container should have an Allocator member data, which is used internally.

Question: what happens, for example, when we swap() two containers that use different allocators?

Must the allocators be swapped as well?

Must all elements of the container be reallocated when the allocator is changed?

View 7 Replies View Related

C++ :: Bidimensional Array Container

Jun 24, 2013

I need to create an array container with the same structure as double myA [100][100];. But I cannot declare it as array<double, 100, 100> myA; however I do need this container for its format. How can I make it work.

View 6 Replies View Related

C++ :: How To Create A Container Class

Feb 9, 2013

I know that it's a class that contains data from another class I just do not know how to make them both work together.

View 1 Replies View Related

C++ :: How To Properly Iterate Over A Container

Oct 31, 2013

so i have a container called Source that is of type std::map<std::string, std::vector<std::string>> but when I try to print it with this function:

void Lexer::PrintSource()
{
for(auto Iterator = this->Source.begin(); Iterator != this->Source.end(); Iterator++)
for(auto SubIterator = Iterator->begin(); SubIterator != Iterator->end(); SubIterator++)
cout<< *SubIterator << endl;
}

i get these errors:

Lexer.cpp: In member function 'void Lexer::PrintSource()':
Lexer.cpp:29:42: error: 'struct std::pair<const std::basic_string<char>, std::vector<std::basic_string<char> > >' has no member named 'begin'
for(auto SubIterator = Iterator->begin(); SubIterator != Iterator->end(); SubIterator++)
^
Lexer.cpp:29:76: error: 'struct std::pair<const std::basic_string<char>, std::vector<std::basic_string<char> > >' has no member named 'end'
for(auto SubIterator = Iterator->begin(); SubIterator != Iterator->end(); SubIterator++)
^

View 6 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved