using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApp2
{
class Program
{
static void Main(string[] args)
{
string userName = "";
int userAge = 0;
int currentYear = 0;
Console.Write("Please enter your name: ");
userName = Console.ReadLine();
Console.Write("Please enter your age: ");
userAge = Convert.ToInt32(Console.ReadLine());
Console.Write("Please enter the current year: ");
currentYear = Convert.ToInt32(Console.ReadLine());
Console.WriteLine("Hello World, my name is {0} and I'm {1} years old, I was born on the year {2} .", userName, userAge, currentYear …Run Code Online (Sandbox Code Playgroud) 所以它说:
public int HoursWorked { get; set; }
Run Code Online (Sandbox Code Playgroud)
相当于......
private int hWorked;
public int HoursWorked
{
get
{
return hWorked;
}
set
{
hWorked = value;
}
}
Run Code Online (Sandbox Code Playgroud)
我有两个问题......
简单地调用"HoursWorked"的简单命令如何将"hWorked"带入其中?
我也不完全明白"价值"的价值是什么
感谢您的帮助!
我已经在这方面工作了一段时间,目前我很难过。该程序的起始要求是接受一个字符串,为该类创建一个对象,并将其转换为一个字符链表。我在整个类中遇到了麻烦,因为当我尝试在 while 循环之前的 Main 函数中预定义一个新对象时,我收到错误charchain.cpp:(.text+0x20): undefined reference to linkedChar::linkedChar()我已经测试了该课程并成功转换为字符链表。
#include <iostream>
#include <iomanip>
#include <string>
using namespace std;
struct node {
char data;
node* next;
};
class linkedChar
{
private:
node* head;
public:
string str;
linkedChar();
linkedChar(const std::string s){
head = NULL;
strToLinkedChar(s);
}
node* add(char data)
{
node* newnode = new node;
newnode->data = data;
newnode->next = NULL;
return newnode;
}
node* strToLinkedChar(string str){
head = add(str[0]);
node* curr = head;
for (int i = 1; i …Run Code Online (Sandbox Code Playgroud)