In checkLogin.php
you could try putting:
session_start();
since everywhere you use sessions, should include this.
In checkLogin.php
you could try putting:
session_start();
since everywhere you use sessions, should include this.
If you feel your question has been answered, could you mark it as solved and give rep to those who you think has helped you?
Thanks :)
by that i meant do you know of any good ways to learn C++ or Java and any good websites.
Try Here Or just search for C++ tutorials to help get you started. Once you are familiar with the basics, you can start building up and up and up (OOP) =)
we had to make a bridge traffic light signal work by controlling both sides of the bridge
There we go! Get yourself a Raspberry Pi, some LEDS and a breadboard.. You can develop your C++ skills in recreating this, it would be a fun project to do as well!
1) the course is called Computer AS/A level so i take it that wont teach me the skills i need? so instead of this course what course would you recommend for going on to studying compuer science at university?
This is correct. At least, from my point anyway. Most of the experiences that I've had is that people come into the University enviroment from studying AS/A-Levels and do not know about programming, or, the mathematics behind computing and therefore struggle. It is also important to note that the first year of your University course is a year where everyone has the ability to get onto the same level as everyone else (remembering, everyone has come from a different background!)
That being said: I don't think you should rule out AS/A-Levels and speak to your teachers about the content of the course, and, in your own time, use it to study the things that you will need in order to allow for progression.
2) Yeah Java and C++ are the languages i would like to get into its just i have no real way to learn the languages. So if you have any pointers it will be highly appreciated :)
It's really hard to say which one I recommend choosing first as I do not know your programming background. Specifically, I choose NOT to read from books as these are often written from the prospective of the person writing them so you end up in some way …
As @prit has said, you should pick something YOU enjoy. Saying that, have you thought about the idea of online compilers / text editors? Using PHP and Ajax to maybe have a real-time text editor online where multiple people could get involved?
Okay, it seems like you're from the UK and you're in the United Kingdom so here is some advice:
1) Try to stay away from A-Levels (especially in Computing!) Most Computing courses at A-Level will not teach you the vital skills that you need in order to progress onto further education and your future work. You should ideally choose the type of Computer Science related topic. However, specifically in the UK Universties most of the courses depend on programming and therefore this becomes a major importance of this. Choose College after your school days are over.
2) Do not learn VB or C unless you have a series view of doing it, as, you are not likly to do any of these languages when you decide to go to University to study Computer Science. Instead, you should attempt to read up on C#, Java and C++ as these are the most favoured languages to guide you.
3) Learn other technologies. Again, Computer Science courses are pretty open on the types of Operating systems you can use. It's always a good idea to learn Linux and the GCC compiler because this will always come in handy when you decide to go into University or infact, work.
4) Depending on the Universit(s) you plan to go to (Do you have any idea?!) To study this Computer Science course, you should look at their course content and see what is expected from you. I.e. Computer Programming: What languages? What type of Porgramming will …
haha o'god! I don't like this >.<
Earlier today I could not sign in and it told me my username + password combonation wasn't right. But, I had not changed it? It worked after I re-set my password. Nothing changed on my account, so I don't think I've been "Hacked" Any ideas?
P.S. now I'm getting a blank chat window..
What is going on?
@christinetom - That's great! The compiler will specify the type based on the type of variable passed through. Good luck and thanks for marking this as solved :)
You need to do some research on Templates. This clearly would not work in main because there is no way at run-time to determine what types are the variables. (In this example, anyway).
The correct thing would be to do the following:
#include <iostream>
#include <cstdlib>
#include <string>
using namespace std;
template<typename T>
T declareVariable(T theVariable)
{
T temp = theVariable;
return temp;
}
int main()
{
string value = declareVariable<string>("hello");
cout << value;
}
Notice how in main I can now allow for the variable to be declared so the compiler knows at run time?
I can therefore do this for an interger as well:
int value2 = declareVariable<int>(123);
This should be the solution :)
Remember, Google / DaniWeb are your friends.
Why are you not including the following:
#include <iostream>
using namespace std;
It compiles fine entering ^^ on GCC
Hey, thank you for the reply. The values are just simple double
values with nothing seriously data-intensive about them.
The program will be running for 20 minutes or so, depending on how long each recoding is for. So I can just dump the values that have not had any matches after a certain period. I just don't want to store massive amounts of data inside memory and for it to dramatically slow the program down?
Thanks
I'm working on a project that generates roughly between 13x512 values in which I compare at run-time. So the program outflow will be sort of as follows:
The problem is, I don't know whether or not the quickest method would be to store the extracted values inside a text file and then read them in, or, just store inside memory and if I am storing inside memory, is there a quick way to access these? Such as memory mapping?
Thanks
Forgive me if I'm wrong.. But, doesn't "scripting language" imply that the code is therefore interpreted and not compiled? So generating C/C++ code from the inputted scripting language to then compile using C/C++ seems to defeat the object here.
I guess the scripting language/lexer is written in C++? If so, shouldn't therefore the lexer decide how the code is interpreted?
I have no idea how it is written as I haven't done anything like this in many, many years and my experience then was lacking a little; but, I'm sure someone else could probably offer a better solution to this problem.
I don't get what you mean by "code generation"? Please can you be a bit more specific about this. Are you talking more of say a drop down menue saying "Switch statement" and it'll generate a switch statement? Or.. A GUI where you drop buttons and it generats the code?
No problem :) Please make this thread as solved and give rep to those who helped you
@diafol makes good points here.
You have to remember that Java and PHP are completely different languages, so, it's really difficult to suggest which one will be better, because it hugely depends on the situations and the development projects. Let's assume that you were developing for the web, using a Java Applet for a web project might seem like a good choice, until you take a look at all of the security risks associated with this (hence why there are very little java applets online today!)
It seems kind of a weird question, are you sure that you didn't mean Javascript?
What operating system?
Where do you define the variable $target
?
You shouldn't attempt to just rip code. I don't / Can't tell what the issues are without compiling it myself because I do not have the files needed. When you try to compile the code you submitted, what are the error messages? I don't know, this might be C code, have you tried compiling it using C?
Is this C or C++ code? What are the error messages you get once you declare what ulong is?
input.c(375) : error C2065: 'ulong' : undeclared identifier:
Are you declaring ulong
? i.e. typedef unsigned long ulong;
This might fix the other errors you have, I'm unsure since I don't have access to the full source code.
It's difficult to say what would be useful as I do not know what the specifications are or how the program is suppose to store its data. Maybe when you have finally decided on the structure etc.. You should come back and ask that question? Alternatively, you could read "Arrays vs Maps" etc on Google and match them to your situation
Wow.. Where to begin (lol). It compiles, atleast ;-)
I don't really get your question, but, I assume you're looking for some hints about OO and your code. So I will aim to try my best to offer you some, but, others may have more to offer.
First off, we'll start with the actual class:
class playerClass {
public:
void coolSaying(){
cout << "Class output" << endl;
}
};
In here you don't create a constructor, so, how are you going to call the method "coolSaying"?
Just to note, you have a LOT of variables (line 24-57) Do you really need to use all of these variables? They should also be in the class "playerClass" (note that it is good practice to always name your class with a cap letter "Player") So therefore, your class will look something like this:
class Player {
public:
Player(); // Default empty constructor
void coolSaying();
protected:
// All the variables associated with the class "Player"
};
You declare a lot of functions as well, these, should be in the class as well as members of the class and not outside of the class. Your main should be as empty as possible, you are not using the OO techniques to their advantage.
Here is how I would structure it:
You would have a "PlayerClass" this would be your main initial class containing all of the variables and methods that are generic to ALL of the characters in the game. I would …
Just realised the above code wouldn't work. This will:
#include <iostream>
using namespace std;
class Foo {
public:
Foo()
{
counter++;
}
static int getCount()
{
return counter;
}
protected:
static int counter;
};
int Foo::counter = 0;
int main(int argc, char *argv[]) {
Foo f;
Foo b;
cout << Foo::getCount() << endl;
}
My bad :) http://ideone.com/X5GPKA e.g.
1) Are you sure you're entering the right details?
2) Are you sure you have permission to access the database?
3) Are you sure you're connecting to the right database?
The error message it gives, is pretty clear. What's there not to understand?
@bob - Some others may have a better more effective method to do this, but, just inside the while loop you can create an if statement that checks to see if the number is == 0 and if so, put the number back to 7.. Here:
if(guessnumber == 0)
{
guessnumber = 7;
}
Hope this helps :)
@bob - Here you go
//****************************//
//*****DO NOT TOUCH THESE*****//
//****************************//
import java.util.*;
import java.io.*;
class NumberGuessingGame{
public static int num; //variable to hold randomly generated number
public static int guess; //variable to hold user inputs
public static String ans; //variable to hold user input for y/n
public static int guessnumber = 7; //variable to hold number of guesses
public static int correctguess; //variable to hold number of correct guesses
//the main method
public static void main(String[] args) throws IOException{
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
//introduction
System.out.println("Welcome to the Number Guessing Game!");
//loop to allow the user to play again
ans = "y";
while(ans.equals("y")){
numberGenerator();
System.out.println("\nI have generated a random number between 1 and 100. Please guess what the number is.");
//TASK 1: limit the user to only 7 guesses
guess = Integer.parseInt(br.readLine());
//TASK 2 & 3: write in the conditions for when the user's guess is too high, too low, or correct
//if the guess is correct, the user should not be able to keep guessing
if(guess > num){
System.out.println("Your guess is too low.");
guessnumber--;
}
else if(guess < num){
System.out.println("Your guess is too high.");
guessnumber--;
}
else if(guess < 0){
System.out.println("You have entered a number below 0. Would you like to try again? (y/n)");
}
else if(guess < 100){
System.out.println("You have entered a number above 100. Would you like to try again? (y/n)");
}
else if(guess == num){
System.out.println("CONGRATULATIONS! You have guessed the number correctly! Would you like to play again? (y/n)");
correctguess++;}
if(guessnumber == 6){ …
This isn't the code I suggested you to use. Anyway, it looks like on line line 27 you terminate the while loop, so therefore, it cannot go any further inside the program. Remove this }
Indent code!!!
P.s You also need to implement the functionality of guessnumber for the program to allow for the number of guesses allowed. I'll give you a hint to this, since I get told off for giving out the answer..
If we Increment a number, we add ++ so i++
and if I was (0) it would increment upwards. 0, 1, 2, ....., 10
In this case, we need to decrement.
I hope this helps.
@Bob mhm weird. Post the code that you're currently trying to run and I will take a look at it.
@bob - What version of Java are you running? On my machine, it runs completely fine..
Surely something like this..?
If you have a static variable called "counter" and then increment it by 1 each time the constructor is called then this should work.
#include <iostream>
using namespace std;
class Foo {
public:
Foo()
{
counter++;
}
int getCount()
{
return this->counter;
}
protected:
static int counter;
};
int Foo::counter = 0;
int main(int argc, char *argv[]) {
Foo f;
Foo b;
cout << Foo::getCount() << endl;
}
The above is just an example to demonstrate. :)
@bob - You need to be able to terminate the program if the user enters "n" after the first guess.
Therefore just after line 80
inside this program you should enter: System.exit(0);
to stop the program from repeating itself and therefore exit from the loop.
@JamesCherrill - My bad. I was in a rush and therefore wanted to fix the problem over offering any tits or solutions how to fix the above code.
There are a lot of errors and syntax flaws within the submitted code and in no what what I typed was meant in an insulting way, my apologisies if this come across like so.
The code that I gave, should, no longer give you an infinite loop (From the last time I compiled it).
You should therefore break the code up. For example:
if(guess > num){
System.out.println("Your guess is too low.");
}
else if(guess < num){
System.out.println("Your guess is too high.");
}
else if(guess < 0){
System.out.println("You have entered a number below 0. Would you like to try again? (y/n)");
}
else if(guess < 100){
System.out.println("You have entered a number above 100. Would you like to try again? (y/n)");
}
You do not need so many else if statements, since, the output for each one of these is the same? If the output was different then I could understand why you would need more than one statement, however, 1 function which returns a Boolean depending on whether the guess is right or wrong SHOULD be enough. I.e.
if(numberGuessed)
{
// this is true;
}else{
// this is false;
}
Please feel free to post back if there are any more suggestions you would like making.
It's been a while since I've looked at Java, so, forgive me if this does not work. In brief, what you're trying to do is delcare a method within a method - This is not allowed hence the error you're getting.
I have fixed the error, however, since you're declaring "NumberGuessingGame" as a public class, it therefore should exist in it's own file.
EDIT: I have also fixed the loop error (Yes, I'm in that good of a mood!!)
//****************************//
//*****DO NOT TOUCH THESE*****//
//****************************//
import java.util.*;
import java.io.*;
class NumberGuessingGame{
public static int num; //variable to hold randomly generated number
public static int guess; //variable to hold user inputs
public static String ans; //variable to hold user input for y/n
public static int guessnumber = 7; //variable to hold number of guesses
public static int correctguess; //variable to hold number of correct guesses
//the main method
public static void main(String[] args) throws IOException{
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
//introduction
System.out.println("Welcome to the Number Guessing Game!");
//loop to allow the user to play again
ans = "y";
do{
numberGenerator();
System.out.println("\nI have generated a random number between 1 and 100. Please guess what the number is.");
guess = Integer.parseInt(br.readLine());
//TASK 2 & 3: write in the conditions for when the user's guess is too high, too low, or correct
//if the guess is correct, the user should not be able to keep guessing
if(guess > num){
System.out.println("Your guess is too low.");
}
else if(guess < num){
System.out.println("Your guess is …
I think, this can be completed in Polynormal Time, if I'm honest. If something, for example Euclidean TSP it would still be NP-Hard but not NP-complete.
Hope this helps :)
Have you debugged this? It's pretty hard for someone to compile the code to find the error when we don't have the specific external Libraries.
You should therefore try the following:
This piece of code is a Class, which forms part of the OO techniques built into PHP. OO in itself is a very large subject, so, it would be impossible for me to write a massive post explaining it all, but, you can try the following links:
Within the code we have this:
public $config = array();
The public
in this example tells the interpereter what the restrictions are of accessing this member (where the member is $config
) and it's just assigning an array to this value. I assume you know what Arrays are? If not, there are tutorials online which will help to explain this.
IMO I think you should stay away from classes, and object-oriented programming until you know the basics of PHP or language syntax, logic and structure. Try not to download code, that you do not understand. :)
Hope this helps
As @ddanbe has stated, for Correlation to work, you must correlate between two objects/variables. Please could you explain what it is that you're trying to do?
For example, if image (A) is the unencrypted image and image (B) is encrypted and you needed to therefore match image (A) to image (B) then this can be done using Correlation, but, I don't think you're understanding the processes involved.
Please explain fully.
Noo.. Like having 10 cars to go into work.. You decide one morning to drive the 4x4 but it means that you have to take the sports car with you as well.. But, you don't need the sports car.. Make sense? :P
I think I've found a way around it, just include the implementation from the sub-classes inside the .h
However,
When I have the following:
Window.cpp
Window* Window::Window::createInstanceOf(int theWindow, size_t size) {
Window::Window* w;
w = new Hamming(size);
w = new Hanning(size);
}
I have to include the following files:
Hamming.h
, Hanning.h
And at compile time, I have to link both of these .cpp
files.. BUT what if I was just using Hamming.h
and calling it like:
Hamming* h = new Hamming(100);
Is there a way around this?
Yes - It looks like I'm going to have to have a inheritance hierarchy for this to work.
I need to do this because there exists multiple Windowing Functions, I need to be able to access the w
pointer in another class and this method seems to be the only solution around it.
Thank you for the help :)
I'm attempting to implement the Factory Pattern. I have a class called "Window" which has a class member function which determines which object is being called and then assigns the particular object pointer. I have written the following code:
class Hamming {
public:
Hamming() { }
Hamming(int theSize) {
// code
}
};
class Window {
public:
Window() { }
Window* createInstanceOf(int theWindow, size_t size) {
Window* w;
w = new Hamming(100);
return w;
}
};
I want to be able to call it from the following:
Window* w;
w->createInstanceOf(val, val2);
I get the following error:
error: assigning to 'Window *' from incompatible type 'Hamming *'
w = new Hamming(100);
The problem is, I don't really want to use inheritance or have to include every class inside of the implementation of this class (if i had a .h and .cpp file) because this requires EVERY class to be compiled, and, if I only need to use one instance "Hamming" then I don't need to include the others.
Any suggestions?
This came across me the other day, and it got me thinking. Let's assume I have a very quick question, for example, I had one the other day:
How much implementation can you actually put inside a constructor?
For me, personally, I did not want to make a post about this, as, I wanted a general snappy answer and of course, it is based on peoples opinions etc.. Instead, what I did (shameful) was reach out to a group of C++ developers on Facebook, who, provided me with a quick response in a kind of chat style theme which, involved multiple people commenting and started a kind of debate.
Why can't we have that on DaniWeb? So, if you want, you can ask a 'Quick' question, someone could then pick it up, providing a chat-like response, and, if the question is too long, i.e. Here is a 100000 lines of code, find the error
the people who are responding to the 'Quick Help' can move it to a forum thread where more help can be given.
Just a thought (:
@Mike, thank you for your reply.
Assume I have the following class:
class Foo {
public:
enum dataMember {
A = 0,
B = 1
};
Foo();
Foo(dataMember member)
{
switch(member)
{
case 0:
A a;
break;
case 1:
B b;
break;
}
};
void ProcessCall(Object& obj); // How do I access either "A" or "B" depending on what is passed through in main?
};
I can pass the following:
Foo f(A);
Let's say A
is an object, I need to initialise that object and use it in other functions, so, let's assume now I have the following method:
void processCall(Object& ob)
{
// Note how I've passed in an object.
}
So, from passing in either A
or B
the constructor should know which object to initialise and therefore use. (Assuming "A" and "B" are both classes)
I need to make 'A' and 'B' accessable to all the functions in the class.
Does this make anymore sense? Thank you for the help :)
Sorry if this is hard to understand what I'm trying to do here, but, I do not know how to approach this.
I am using method overloading in my constructors of a class, and I have multiple "Window" functions which are all classes that can be used and I need to initialise an object of one of these classes depending on which is passed through. For example:
I have an enum
which stores the types of Windows available:
enum WindowType {
Barlett = 0,
Blackman = 1,
Hamming = 2,
Hanning = 3,
Nuttall = 4,
};
And inside my class I have the following:
template<typename Inverse>
STFT(Inverse begin, Inverse end, size_t x, size_t y, WindowType type)
{
switch(type)
{
case 0:
// I need to initialise an object, in this case "Barlett"
// Window::Barlett barlett(100); // e.g.
break;
// etc..
}
}
The only problem is that: What if I need to pass this to another method inside a class? For example:
Transform(std::vector<double> &values, Window& {?});
My theory was to use an associative way, and, store it in the class members and use a template, like so:
template<typename T>
Window T;
But this, obviously would not work.
Does anyone have any suggestions to how to approach this?
EDIT:
I realise at main I could initialise which window I want to use and then pass it through to the constructor, however, I just wanted to see if there are any alternatives …
@iamthwee - Were they? I never ever noticed them ha!
One thing I don't like/agree with is this:
1) It seems like a popularity constest. I'm all of recognising peoples achievements in this way but, really, really?
2) What's to stop someone looking at a particular forum, seeing who is the most active / experienced and then them annoying them via PM's in a hope their question would get a reply sooner.
Just food for thought :)
Please could you include an example to your problem? It's kind of hard to find out where you are going wrong, but, here is an example (of what I assume you are trying to do):
// Test.h
class Test {
public:
Test(); // constructor
void doSomethingCreative();
};
And then your implementation of this class:
#include "Test.h" // assuming the header file is called "Test.h"
Test::Test()
{
// constructor implementation
}
void Test::doSomethingCreative()
{
// Method implemenation
}
At compile time, we just need to compile the .cpp
file over the .h
So, therefore your main will look something like so:
#include <iostream>
#include "Test.h"
int main(int argc, char *argv[]) {
Test t;
t.doSomethingCreative();
}
To compile, again, using GCC would be something like:
g++ Test.cpp main.cpp -o main
./main
Hope this helps slightly.