473,399 Members | 3,656 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,399 software developers and data experts.

cipher for C++ object oriented programming

so, here what's i'm trying to do,
when user enter ant statement, the output result will be cipher to numbers, so, i try to assign character to array, when i try to run the code, error occur at array declaration, here what i've got so far:

Expand|Select|Wrap|Line Numbers
  1. #include<iostream.h>
  2. class Cipher{
  3. private:
  4. char code[1] = A;
  5. char code[2] = B;
  6. char code[3] = C;
  7. char code[4] = D;
  8. char code[5] = E;
  9. char code[6] = F;
  10. char code[7] = G;
  11. char code[8] = H;
  12. char code[9] = I;
  13. char code[10] = J;
  14. char code[11] = K;
  15. char code[12] = L;
  16. char code[13] = M;
  17. char code[14] = N;
  18. char code[15] = O;
  19. char code[16] = P;
  20. char code[17] = Q;
  21. char code[18] = R;
  22. char code[19] = S;
  23. char code[20] = T;
  24. char code[21] = U;
  25. char code[22] = V;
  26. char code[23] = W;
  27. char code[24] = X;
  28. char code[25] = Y;
  29. char code[26] = Z;
  30. public:
  31.  
  32. void SetCode();
  33. void GetCode();
  34. };
  35. void Cipher::SetCode()
  36. {    
  37. cout<<"Enter Cipher Code:";
  38. cin>> code;
  39. };
  40.  
  41. void Chiper::GetCode()
  42. {
  43. cout<<"Chiper Result:"<<code;
  44. cout<<"\n";
  45. };
  46. int main()
  47. {
  48. Cipher Code1;
  49. Code1.SetCode();
  50. Code1.GetCode();
  51.  
  52. return 0;
  53. };
Mar 28 '13 #1
3 1724
r035198x
13,262 8TB
1.) Use code tags when posting code
2.) Don't ignore error messages. They contain vital information that teaches you what is wrong with your code. Learn to read those messages and try to understand them.
3.) Arrays are easy to use when use them with loops.
Mar 28 '13 #2
Rabbit
12,516 Expert Mod 8TB
There is a ton of stuff wrong with your code.

You can't declare an array like that. Also, strings have to be surrounded by double quotes. If you are trying to declare and initialize at the same time, you need to do this:
Expand|Select|Wrap|Line Numbers
  1. char code[3] = {"a", "b", "c"}
Arrays start at index 0.

You are reading your input into your array, pretty sure you don't want to do that. Read it into another variable.

You are also just outputting your array varible, that makes no sense either. I honestly don't even know what your purpose if for the array. You haven't described the cipher you're trying to implement.
Mar 28 '13 #3
I would recommend reading a tutorial like this one below:
http://cplusplus.com/doc/tutorial/arrays/
Apr 3 '13 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: ggg | last post by:
I'm looking for a complete project/application done with heavy use of of object-oriented programming & design. Preferably something well documented and/or commented so that I can pick it apart...
5
by: Martin | last post by:
When was inheritance intruduced into object oriented programming? More generally, does anyone know or have any sources on when the different features were introduced into object oriented...
65
by: Roger Smythe | last post by:
A means for the progressive decomposition a problem space into increasingly simpler component parts such that these component parts represent higher levels of conceptual abstraction, and are...
34
by: Pmb | last post by:
Hi. I'm new to this group. I'm refreshing/learning C++ and am starting to learn Object Oriented Programming (OOP). In discussing this with people I came up short as to what the benefits of OOP are....
4
by: mihai | last post by:
I wander what is the penalty of speend for using object oriented programming (C++) against the play C. Have a nice day, Mihai
14
by: Rookie | last post by:
Is C an object oriented programming language?
8
by: Dale | last post by:
I've searched Amazon and read probably 100 reviews but can't find what seems to be any book that is widely accepted as the definitive book on object oriented programming design and techniques. And...
47
by: Thierry Chappuis | last post by:
Hi, I'm interested in techniques used to program in an object-oriented way using the C ANSI language. I'm studying the GObject library and Laurent Deniau's OOPC framework published on his web...
3
by: KiranJyothi | last post by:
Hi All, I am new to the software languages and wanted to learn C++. It seems that C++ is neither(completely) an object oriented programming nor(completely) a proceduarl programming. So, I...
139
by: Joe Mayo | last post by:
I think I become more and more alone... Everybody tells me that C++ is better, because once a project becomes very large, I should be happy that it has been written in C++ and not C. I'm the only...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.