C++ :: Direction On Implementing Alegrabic Functions

Apr 30, 2013

implementing an algebra function.(a+b)(a-b).does c++ support this sort of function.Did a quick search on google and all of them suggested using libraries like boost. is there anyway to do this without a library?

View 3 Replies


ADVERTISEMENT

C++ :: Implementing Functions In Priority Queue

Oct 28, 2014

I know queue but with priority queue i am really amateur. How to implement some functions in priority queue.

template <class T> class PRIORITY_QUEUE {
private:
T *items; // array of queue items
int rear;
int maxSize; // maximum size of queue

[Code] ....

and what does heapify mean???

View 8 Replies View Related

C :: Displaying Direction From A Table Of Values

Oct 1, 2014

Below, is the program I completed so far. I need to write a C program that reads in a stream of integer values, each representing an (x,y) pair on the cartesian plane. It then says I need to display the distance and direction from one point to the next. I tested it out, and it works.I need to use a conditional statement, and I'm a little confused how to display the direction(right, left, up, or down).I think I need to use an. "If" statement with my first one being something like:

If (y2 = y1) && (x2 > x1)

and I'm not sure what else to put,or if this is wrong. And with y staying the same and x increasing, the direction would be right.

Code:
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
int main(void)
{
int x1, y1,x2,y2,x3, y3,x4,y4,x5,y5,x6,y6; //x and y coordinates

[Code] ....

View 1 Replies View Related

C++ :: Vector Addition With Magnitude And Direction

Sep 29, 2013

i new to c++ programming. i have a program due soon in vector addition. i am to design should be able to add vectors with certain magnitude and direction and give its resultant magnitude and direction (i know how to do this mathematically but programming is not working. the user should be able to select how many vector he/she wants (i don't know how to do this, so i added 3 vectors). here's my work - i did this purely algebraically. it's still incomplete but it compiles. my "if else" statement also doesn't respond correctly.

#include <iostream>
#include <string>
#include <vector>
#define PI 3.14159
#include <math.h>
std::vector<int> v; // declares a vector of integers
using namespace std;

[code].....

View 4 Replies View Related

C++ :: Finding Rotation Direction From Two Orientations?

Mar 4, 2014

It is technically not a programming question and is more maths oriented. It has to do with game AI and specifically getting the AI to rotate correctly. I am trying to create the base method that handles AI rotation. It will take a target orientation and rotate the entity from it's current orientation to that target orientation.

Let's say we have a Entity that has the orientation of 1.57079 Radians (90 Degrees) and we want to change that Entity's orientation to 0 Radians (0 Degrees). How would one find the correct way to rotate from just them two orientations (IE find the shortest rotation direction from a current orientation to a target orientation)?

As my implementation stands now the Entity rotates just fine I think but always in a clockwise rotation (Because I can't figure out how to determine the best rotation direction). For example using the previous number (1.57079 Radians to 0 Radians) the Entity will rotate all the way around 270 Degrees clockwise instead of rotating just 90 degrees counter-clockwise.

I have thought about possibly projecting vectors a short distance forward from the current orientation and target orientation to figure out the rotation direction but not sure if that is a good way to implement it.

View 1 Replies View Related

Visual C++ :: CDialog Resize In One Direction

Oct 27, 2014

Is there any way to allow user to resize a CDialog only in one direction ? I mean, by width, but not by height ? How ? I noticed that overriding WM_SIZE, I can do nothing about this issue ...

View 2 Replies View Related

C++ :: Program That Prints A Triangle Of Symbols In A Certain Direction

Jan 12, 2015

So I need to make a program that prints a triangle of symbols in a certain direction.

For example: Code: How many rows? 3

@
@@@
@@@@@

How to do that. It's rare that I post without figuring anything out, but I'm just simply not sure. I have a program that prints a triangle in a similar direction, so maybe if I could get some hints as to what to do with that (HINTS, not direct source code) .

Code:
#include <iostream>
#include <iomanip>
using namespace std;
int main ( ) {

[Code] .....

View 6 Replies View Related

Visual C++ :: SDI App - Constraint Mouse To Move Only Horizontal Direction If Shift Key Pressed

Apr 23, 2015

In a SDI app, I constraint the mouse to move only an horizontal direction, if "Shift" key is pressed ... here is the code:

Code:
void CTestMouseView::OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags) {
// TODO: Add your message handler code here and/or call default
if(GetKeyState(VK_SHIFT) < 0) {
CRect rect;
GetWindowRect(&rect);
GetCursorPos(&m_point);

[Code] ....

Nothing complicated, and it works well ... except one thing: when I press the shift key and the mouse is moving by SetCursorPos, is moving pretty slow ... why ? I can not figure out why ! For testing, I attached the test project ...

View 13 Replies View Related

C/C++ :: Implementing T9 Using A K-ary Tree?

Dec 17, 2014

I'm trying to implement a T9 (predective text) project in c++ using k-ary Tree.

I would like to understand how can I add the words in the Tree and how can I display them later.

inside each node of the tree I have a linked list (for the words) and a vector of pointers to access the next node

Here are my structs :

struct NodeList{
string data;
NodeList * next;
};
struct List{
NodeList *head;

[code].....

View 1 Replies View Related

C/C++ :: How To Access Linked List Functions From Stack Class Without Functions

Mar 20, 2014

I'm a little confused by my programming assignment this week. I've been working at it Wednesday and I've made progress but I'm still confused as to how I'm supposed to do this. The class I made is called Stack, and it's derived from a template class called StackADT. We also utilize a class called unorderedLinkedList, which is derived from a class called linkedList.

We're supposed to implement all of the virtual functions from stackADT in the Stack class. The Stack data is stored in a an unorderedLinkedList, so what I'm confused by is how to implement a few of the Stack functions because there are no functions in unorderedLinkedList which we could call to manipulate the data.

As you can see from my attached code, I'm really confused by how I'm supposed to implement the pop() and top() functions, and I also think my initializeList() function is wrong. We don't have any similar functions in unorderedLinkedList to call, so I'm at a loss of how i'd access my unorderedLinkedList. My initial thought was to call the similar functions in the class that unorderedLinkedList was derived from, linkedList, but I'm unsure of this is what we're supposed to do, or if theres actually a way to access my unorderedLinkedList without having to use the functions from the base class.

NOTE: We're not allowed to modify stackADT, unorderedLinkedList, and linkedList.

Stack.h

#include "stackADT.h"
#include "unorderedLinkedList.h"
template<class Type>
class Stack: public stackADT<Type>{
template <class T>
struct nodeType
{
T info;
nodeType<T> *link;

[Code]...

View 3 Replies View Related

C++ :: Implementing Adjacency List?

Mar 1, 2014

Today I am refining my skills on graph theory and data structures. I decided to do a small project in C++ because it's been a while since I've worked in C++. I want to make an adjacency list for a directed graph. In other words, something which looks like: 0-->1-->3 1-->2 2-->4 3--> 4-->This would be a directed graph with V0 (vertex 0) having an edge to V1 and V3, V1 having an edge to V2, and V2 having an edge to V4, like this:

V0----->V1---->V2---->V4
|
|
v
V3

I know that in order to do this, I will need to create an adjacency list in C++. An adjacency list is basically an array of linked lists. Okay, let's see some pseudo C++ code:

Code:
#include <stdio>
#include <iostream>
using namespace std;
struct graph{

[Code] ....

This pseudocode is currently far from the mark. And that is what -- pointers and structs in C++ have never been my strong suit. First of all, this takes care of the vertices that a vertex points to -- but what about the vertex itself? How can I keep track of that vertex? When I loop over the array, it will do me no good to only know what vertices are being pointed to, rather than also knowing what points to them. The first element in each list should probably be that vertex, and then the elements after that are the vertices it points to.

But then, how can I access this first element of the list in my main program?. I would like to be able to loop over this adjacency list to do some cool things with graphs. For example, to implement some graph theory algorithms (sorts, shortest paths, etc) using the adjacency list representation. (Also, I had a question about the adjacency list. What is different than just using a list of arrays? Why can't I just have a list with an array at each element in the list?)

View 2 Replies View Related

C :: Implementing GUI On Linux Platform

Jul 6, 2014

I am an experience C programmer but never implement GUI.

I need to make a demo implementation that will be run on Linux and will implement GUI.

I searched the WEB and found lot of information, among is implementing the GUI in HTML and run the API through web browser.

How can I make such implementation in C?

View 2 Replies View Related

C++ :: Implementing Ksmall As A Function

Mar 19, 2013

Implement ksmall as a C++ function. Use the first item of the array as the pivot. This is what I have so far, but everytime I compile it crashes ....

#include <cstdlib>
#include <iostream>
using namespace std;
int kSmall(int k, int anArray[], int first, int last);

[Code] ....

View 4 Replies View Related

C/C++ :: Implementing Dfa For A Binary String With At Least Two 0 After Every 1?

Feb 24, 2013

i want to implement dfa that accepts the binary string with at least two 0's after every 1 .....

View 3 Replies View Related

C/C++ :: Array Of Functions Pointing To In Class Functions With Arduino

May 3, 2013

At the moment im trying out with pointing to an array of functions. I got this working as following:

typedef void (* functionPtr) ();  
functionPtr functions[2][2]={{do11,do12}, {do21,do22}};    
void do11(){DEBUG_PRINTLN("11");}
void do12(){DEBUG_PRINTLN("12");}
void do21(){DEBUG_PRINTLN("21");}
void do22(){DEBUG_PRINTLN("22");}    
void loop(){
         A=0;
         B=1;
         functions[A][b]();
}  

But now I'm trying to use this to point to a function inside a class so instead of do11, i want to be able to point to Basic.Do11. Somehow this doesnt work and I keep on getting this message:

error: argument of type 'void (Basic::)()' does not match 'void (*)()'

View 2 Replies View Related

C++ :: Implementing Stack Using Class Template?

Dec 5, 2013

The following program is designed to demonstrate class templates. The program will evaluate postfix expressions input to the console by pushing them in a stack, and then popping them and evaluating them as such, (ex. entering 3 4 + would equal 3+4 = 7).

The code is below. We are not to modify it, but to fill in the blanks, the places filled in indicated with two asterisks for a line, and one on each side for a part of a line. If I didn't know what to enter (if anything), I put three ?s. If you want to copy and compile for yourself, look for all the *s and ?s.

1) I'm turning up all sorts of errors in the main program file (prog5.cpp) having to do with stacktype.cpp. It has been removed from the program, as it is included at the end of stackType.h. Most of them are "cannot convert 'this' pointer from StackType to StackType<stack> &'. How do I fix that?

2) The program supposedly lacks a default constructor, and it keeps turning up that 's' is an array of unknown size (do I call StackType or stack or what?).

stackType.h Code: #pragma once// Catherine Stringfellow and Trey Brumley
// A Stack is a data type, which stores values in an order where values are added to the top of the stack when pushed,
// and when popped, remove and return the value from the top of the stack.
// Class specification for Stack ADT in file StackType.h
using namespace std;
static const int MAXITEMS = 50;

[code].....

View 11 Replies View Related

C :: Implementing Custom Behaviour But Something Fails

Jan 2, 2015

I am creating a special struct with unknown functions. I use this approach:

Callbacks.h Code: #ifndef CALLBACKS
#define CALLBACKS
struct Callbacks;
struct Callbacks* getNewCallback();

[Code]....

When I ran it only the calls from doers array is called 7 times normally, and donters only one time. Why is that? When I call doers from the second loop, it prints the doers functions again....and only one call to donters is made to the first static inline donter functions __dont1()...

View 7 Replies View Related

C :: Implementing Selection Sort Algorithm

Jun 14, 2014

So i'm trying to implement the selection sort algorithm and it seems that the code is fine but...

Code:
#include <cs50.h>
#include "helpers.h"
void
sort(int values[], int n) {
// TODO: implement an O(n^2) sort

[Code] ....

I keep getting these errors and i don't understand why:

/usr/lib/gcc/x86_64-linux-gnu/4.6/../../../x86_64-linux-gnu/crt1.o: In function `_start':
(.text+0x20): undefined reference to `main'
collect2: ld returned 1 exit status

View 3 Replies View Related

C++ :: Implementing Stack Data Structure As ADT

Mar 7, 2014

So I've been working on implementing a stack data structure as an ADT, the program compiles, but when I try and push elements on top of the stack, for some reason the stack is full.

#ifndef H_stackADT
#define H_stackADT
template <class Type>
class stackADT {
public:
virtual void initializeStack() = 0;
virtual bool isEmptyStack() const = 0;

[Code]...

View 4 Replies View Related

C++ :: Implementing Collision Detection Correctly

Sep 10, 2014

I'm making a 2D Terraria-like (side-scrolling RPG with destroyable blocks) game with SFML 2.1, and I have no clue how to correctly implement collision detection. Meaning that I have been successful at making it work, but it's not clean and definitely not dynamic.

By example, I mean design wise. What parameters should collision functions take? Where should these functions be located? The same 2 questions for collision reaction. Since I have multiple things that need to collide with each other (player with enemy, player with items, enemy with items, enemy with enemy, player with player, etc...), and the world has to be treated differently, things get complicated. There is no block class, just a vertex array, so collision with the world is based purely on coordinates taken from that array in the world class, which, considering it's the world and not something like a player or an enemy, doesn't inherit from the same base class that they do.

View 7 Replies View Related

C++ :: Implementing Class To Simulate A Disk

Oct 1, 2013

So this code compiles without any problem but it is not producing the correct output. I know there's a problem in either my getBlock or putBlock functions but I can't see it.

Currently the output is "Should be 32 1s: "
"Should be 32 2s: "

There should be 32 1s and 32 2s and nothing is coming out.

#include <iostream>
#include <fstream>
using namespace std;
class Sdisk {
public :
Sdisk(string diskname);

[Code] .....

View 3 Replies View Related

C/C++ :: Implementing A Binary Search Tree?

Mar 20, 2014

I'm working on a programming homework that asks us to implement all the functions of a Binary Search Tree using templated classes. I'm almost done with it but I'm sort of stuck with the last part which is the `search` function. For this part the homework asks for the following requirements

Quote

Node<T>* search(T value, Node<T>* subtree)

if the current node's value is the one we're search for, return a pointer to itif the current node's left and right subtree's are empty (both m_left and m_right are looking at nullptr) then return the nullptr to indicate we didn't find the valueif the value is less than the current node's value, return the search of the left subtreeif the value is greater than or equal to the current node's value, return the search of the right subtreeMake sure to only traverse a subtree if it's not null

View 1 Replies View Related

C/C++ :: Implementing Tree From Array - Use Of Pointers?

Jan 23, 2015

I'm trying to implement a tree from an array an first I used add_left_node() and add_right_node methods (as requested in the problem I have). But I'm a bit confused about the use of pointers in this. Is using &node the same as defining *pointer=node and then using "pointer" in place of &node?

I get only the value of the first node I created. For the node's left and right values I get long numbers displayed, so I think I have interfered with the addresses.

This is my main method:-

int main(){
bintree_node q = bintree_node(1);
bintree_node *poin=NULL;
poin = &q;
add_left_child(poin, 5);
add_right_child(poin, 6);

[Code] ....

View 6 Replies View Related

C++ :: Implementing Signature Block Class

Sep 29, 2013

For class we are required to implement a signature block on all our assignments. To do this I've created a Signature Block class, but I'm having trouble implementing it. When I try to compile in Dev C++ I get this error:

[Error] request for member 'toString' in 'myblock', which is of non-class type 'SignatureBlock()'

Here is the code:

Assignment1.cpp

#include <iostream>
#include <string>
#include "SignatureBlock.h"
// Assignment 1: Requests user's name and says "Hello."
using namespace std;
int main(int argc, char** argv) {
string name;// string to store user's name
SignatureBlock myblock();// create a signature block object

[Code] ....

View 4 Replies View Related

Visual C++ :: Implementing Parameter Argument To Exe

Nov 5, 2013

i have this Stealth Injector source from internet so this program is for injecting .dll to an .exe this program was made by someone to used for cheating in online game but i need to use this program in my private server game online to tell the game client .exe the server IP, that is stored in a dll file.. the problem is i don't want the player to directly execute this program, but they need to run the game patcher first to do the patch.. so i need to put some secret parameter argument that will block player from direct execute..

i know nothing about c++ i only know that you need to use main(int argc, char *argv[]) i've try to put something like this

Code:
int main(int argc, char* argv[]){
stringstream sparam;
string param;

[Code].....

the code works fine but the rest of code won't executed..

i've attached the cpp and header files for you guys to check source.rar

View 3 Replies View Related

C :: Implementing Non Blocking UDP Socket By Select Function

Apr 22, 2013

I wanted to create an asynchronous/non-blocking udp client server application where the client and server were supposed to chat away with each other without waiting for each other's turns. I came to know that this could be done by select()... here is my Server(Mentioning only the communication part):

Code:
fd_set readfds,writefds;
while(1){
FD_ZERO(&readfds);
FD_ZERO(&writefds);
FD_SET(sd,&readfds);
FD_SET(sd,&writefds);

int rv = select(n, &readfds, NULL, NULL, NULL);

[Code] .....

At first on the server side I wrote:
int rv = select(n, &readfds, &writefds, NULL, NULL);

But that led to the printing of an entire empty array on the server console when the server initialised in addition to the fact that communication between the server and client was not proper. removing "&writefds" did remove the redundant data but the improper communication issue still persists...

View 3 Replies View Related







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