C# :: Strategy Script - Keep Getting Single Error CS1513
Dec 4, 2011I have been trying to compile a trading strategy but i keep getting a single error CS1513.
I am not a programmer so its very hard for me to fix.
I have been trying to compile a trading strategy but i keep getting a single error CS1513.
I am not a programmer so its very hard for me to fix.
I've reached some sort of paradox while writing my small game. I need an algorithm to decide the winner of the game, but it's a fairly complicated task so i decided to delegate the responsibility to a strategy object, and code a naive(inefficient) algorithm to begin with, then i can easily swap the algorithm for a more efficient one later.
The problem is, that the strategy object needs to know the game, and the game needs to know the strategy object, but as you can see there is no way of doing that since i need to create one object before i create another.
//Wrong code illustrating the concept
Winner_strategy * winner_strategy;
Game * game;
winner_strategy = new Winner_strategy(game);
game = new Game_impl{winner_strategy};
BTW i know that it's best pratice to use unique_ptr, but i don't think it will make a difference here?
I'm trying to print a single linked list backward with functions/classes. I have created the main file and 3 header files. But I'm getting an error on one of the header files, linkedListIterator after adding #include "linkedListType.h". It says that "linkedLlistType.h" is calling itself. And when I try to run it, I get an error of "too many header files." I have tried changing the headers many times, but nothing seems to work.
.cpp file:
/*(Printing a single linked list backward) Include the functions reversePrint and recursiveReversePrint, as discussed in this chapter, in the class linkedListType. Also, write a program function to print a (single) linked list backward. (Use either the class unorderedLinkedList or the class orderedLinkedList to test your function.)*/
#include "linkedListType.h"
#include "orderedLinkedList.h"
#include "linkedListIterator.h"
#include <iostream>
using namespace std;
struct nodeType
[Code] ....
header files:
[URL] .... (error in this header file)
[URL] ....
i have two loops ie.
if (n==null)
{
do loop 1
}
else //(n=!null)
{
do loop2
}
now i have to update the above code, with a single loop ie. when n==null or n!=null do the loop 1
how can i update.?
can i do like this
if(n==null ||n=!null)
{
do loop 1
}
is || operator above does the job what i expected
I have to make my program display days 1-30 along side numbers increasing by 5 each day beginning with 6 on the first day. I wrote 2 for loops on separate tabs but now I want to know if its possible to combine them into 1.
For loop 1
int day,;
for (day = 1; day <=30; day = day + 1)
For loop 2
int candy;
for (int candy = 6; candy <=151; candy = candy +5)
I'm trying to create a Makefile for a single fie ( mycod.c)
What is the syntax?
I am writing a program, the trouble is is that it uses a single thread and is SLOW.
View 10 Replies View RelatedI have some problems with copying a single character from one char into another. How do I do that? Here is the function I am using
Code:
void
text_col (char line[]) {
char line1[1];
int l, ii;
l = strlen(line);
[Code] ....
I am trying to copy in a loop every single character from char line into char line1. That is not working.
Im new to c#. In c++ I have made a window and painted it with dots and concentric circles, like a radar PPI screen. Trying to do this in c#, I can't find how to draw a single pixel on the window.
Also, what should I be drawing on: the form, panel, picturebox...?
I'm trying to compare a single value with a value from my Linked list and if they are same, I want to add the value from the list to new list. In other words I want to create a new List with values with the first one. Here is the code that I made, but it's not working.
This is the code with which I search in the first list for a node with a value. In the main() function I have A.find_city(), so it can start from the start_pointer from the first list:
void List::find_city() {
List *temp1;
int b = 0;
char city[20];
cout << "Enter city: ";
cin >> city;
temp1 = start_ptr;
[Code] ....
This is the code with which I add a node to the new list:
void List::in(List *temp1) {
List *temp2;
if(start_ptr == NULL)
start_ptr = temp1;
[Code] ....
I've got the program for the most part except one part because it's basically wanting me to return 3 values from a single function and I'm unsure how to do this the way it wants me to. The rules:
Call the user-defined function to read in x in the series to be used for calculating the results. Pass a prompt for x as an input parameter, and return the validated x value to main.
After a valid x has been entered, call the same user defined function a second time, to read in y. Pass the prompt for y as an input parameter, and return the validated number of terms value to main.
After a valid y has been entered, call the same user-defined function a third time, to read in z. Pass the prompt for z as an input parameter, and return the validated z value to main.
here i have an assignment, creating a longInt class and using it to calculate large numbers, i dont have a clue how to manipulate a whole array as a single ineteger.
View 7 Replies View RelatedI am making a text encrypter and I have to convert text into ASCII codes. I know how to convert a single character into ASCII -
#include <iostream>
using namespace std;
int main() {
cout<<"Text to ASCII converter"<<endl<<"Enter text to convert into ASCII - ";
char text; //defining input type, which is single character
[Code] ....
Try it here - URL.....Is there any way to run a similar program, which converts a string with spaces into ASCII code?
For Example i have made a text file included some students data. Now i want to change just a single student data. That file should remain same just that student's data replace.
View 3 Replies View RelatedSo, I've made programs like Prime number searchers and such. But the problem is if I use an int or long int variable for the program I am limited by the variable size. I can't search through numbers larger than their memory size. So my question is: Is there a way to allocate memory to a single variable, NOT AN ARRAY, so I can make a variable as many bytes as I want?
View 3 Replies View RelatedI am stuck at a problem where I have two pointers pointing to the same object, and I need to change an int on one of the pointers but point to the same object.
To be more specific, there is an array of Item objects. A long list of items a player can buy. Then, there is the player's inventory, a vector pointer. Whenever a player buys an item, it sets the pointer to the bought object.
The problem arises when he buys two of the same object. I tried to identify the objects with an ID, but it does nothing, because they are just pointing to the same object, and so I have no way of telling them apart.
This is further complicated by the fact that it is a polymorphic object. So, I can't simply make a new every time I buy an object, without making a hassle. Well, at least I am not familiar with that kind of code just yet.
I want to read a single byte from a wifstream. With an ifstream I would use read(), but given that the char type for an wifstream is wchar_t (2 bytes), this is also being used by read(), so how can I read a single byte from such a stream?
View 3 Replies View RelatedI have an MFC application(.exe) in which i am creating an pointer object to CComQIptr<chemst::IChems>myinfo and after this i have using cocreate instance i had created the object launching that object, so Where i am using that CComQIptr object.
I have been creating instance to that COM exe (child exe) and at the end of the function i am releasing that object (myinfo->release).i want to create single instance for it and i want to use them in different .cpp files and finally i want to kill the child exe. Even though i release the object it is still alive.(Visualising in Task manager whether the exe is still alive or not).
I wrote a code which checks if there are any single numbers in an array.e.g.In the next array there is a single number - "3" 4 1 4 3 4 1..Here is an array which doesn't have single numbers in it: 4 1 4 3 3 1
Code:
#include <iostream>
using namespace std;
int single (int arr[], int size)
{
int couple=0;
[Code]....
First I thought to double the number of couples I'll get from my search and find some connection to the length of the array, but it hasn't worked out (signed red).
Anyway, I have an assignment in which I'm supposed to create a program to be used in a library. Basically a database storing all books currently outside the library along with who and when borrowed them. It also says I should use single linked lists.
Now, I've got a general idea of how to make it work but I've stumbled upon a problem. Since the program has to write all the data put into the database in a file and be able to tell the user whether a book has been kept too long by the reader, I figured I'd implement the struct tm to convert the date when the book was borrowed (or rent, whatever, English is not my first language ;p) into UNIX time.
Then, when I'd like the program to tell me which books are being kept hostage by the readers the program would look for a certain record (like a string inside a certain struct) and compare the date inside that record with current date and then the result of this comparison would be compared with a given, defined time limit. Although this is all a different kinda function, it's a bit simplier, I guess, and I think I'll work it out. However to get there at all I need to be able to store the data correctly and there is a problem, which I'll explain on the other end of the code .Here is the code I came up with:
Code:
#include <stdio.h>#include <string.h>
#include <stdlib.h>
#include <time.h>
int DisplayMenu();
int ReturnToMenu();
int AddBooks(char *filename);
[Code] ....
So, my problem is as follows: the date seems to be stored alright, but it's wrong. For checking I had a Code: printf("%d", mktime(&date)"); added and it returned "-1"... As I said, I'm relatively new to coding/programming and my knowledge is rather rudimentary.
By the way: I had one more gremlin haunting me on this one. Namely at the begining of the input to the AddBooks function:
Code:
int flag = 0; do
{
printf("Please type in the book's title:
");
gets(newbook.title);
if (strcmp(newbook.title, "") == 0)
[Code] ....
The do while loop is to ensure 'unempty' input. Without this loop however, the program would display the message "Please type in the book's title:" but it wouldn't wait for input. It's simply jump to the next printf and wait for input then... I figured it might be becuase it took the 'Enter' that was somehow still in the memory after the user confirms his selection in the menu... It's just a guess, though.
I'm a beginner with C and wonder how to include single header files (*.h) in to my project. I mean header files which are not included to the standard installation package.
I thought it would work if I just copy the newheader.h file in to library folder c:MinGWinclude, but it didn't work. Is there some kinf of GCC -command or procedure to add these single header files or how it should work?
All of those standard header files are working well and I don't have any problems with them.
Environment I'm using is MinGW+GCC+Win7.
I need to write a code (in C99). The programe receives an input number (integer) 'n' and then a matrix sized n*n (matrix[n][n]), all numbers are integers. We're supposed to define the matrix's size with malloc. Now the program needs to sort the lines of the matrix (the number in each line), in a single function (!) this way:
even line index (0,2,4,6...): from small to big.
odds line index (1,3,5...): from big to small.
and then print it.
*note: first line is indexed 0, second line is 1, etc.
I was thinking to sort it with bubblesort function with the following if:
if(i%2==1)
do odds sorting.
else
do even sorting.
when i is the index of the row.
my problem is defining the malloc and how do I send the matrix to sorting.If needed I will attach my current (not so good (completly awful)) code and functions as well as an example of what the prog. supposed to do.
I created a simple program that writes some text to two different text files. how to create a program that would retrieve the information from those two files, and put them in a single file, first the content of input1 and then the content of input2. how to do this. Here is the program that I created that creates the two files.
#include <iostream>
#include <fstream>
#include <string>
int main() {
using namespace std;
string input1;
ofstream fout("input1.txt");
[Code]...
I've got a VERY experimental function which takes data stored to a file and assigns it to a multidimensional array on the heap. It's designed for infinite dimensions by recalling itself with updated information but I don't think this is very safe.
The template function creates a heap array using a TYPE**, and recalls itself to create the new dimensions. I want to replace this with the much safer method of assigning just a single heap memory array and then only assign using the recalling method (unless I can find anything else).
To do this though I need to know how single dimensional arrays are stored on the heap, as well as multi-dimensional (for n dimensions). Where I can find this information?
btw I only need this for the Windows operating system, 32bit, I'm not exactly sure what 'C++ style' this is but I'm using Microsoft's Visual Studio Express 2012 as my IDE, so whatever that uses.
what is the process to delete everything from a singly linked list. Like S= 1->2->3->... I want to remove all the values from S and reuse it again to store new datas.
View 2 Replies View RelatedGiven an integer, find the sum of all the digits in the number until the sum becomes a single digit. E.g. sum of digits of 9264 = 21. Then sum of 21 = 3.
View 2 Replies View Related